Skip to content

Commit

Permalink
fix: download frameware path error
Browse files Browse the repository at this point in the history
  • Loading branch information
fishros committed Apr 1, 2024
1 parent 18d0c51 commit 343af3b
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Dockerfile.build.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM docker.io/batonogov/pyinstaller-windows

SHELL ["cmd", "/S", "/C"]

RUN apt install wget && wget https://github.com/espressif/esptool/releases/download/v4.7.0/esptool-v4.7.0-win64.zip

# docker build -t fishros2/fishbot_tool:build_win11 -f Dockerfile.build.win .
# docker run --rm -it fishros2/fishbot_tool:build_win11 /bin/bash
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ def download_thread(self):

firmware_name = os.path.basename(url)
self.put_log(f"[提示]准备从{url}下载固件到{port}对应芯片为{chip}")
path = os.path.join(CURRENT_DIR,firmware_name)
if url.startswith('http'):
self.put_log(f"[提示]检测到固件地址为网络地址,开始下载")
firmware_path = network.download_firmware(url)
firmware_path = network.download_firmware(url,path)
else:
firmware_path = url

Expand Down
54 changes: 54 additions & 0 deletions release_win.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- mode: python ; coding: utf-8 -*-
import os

# 从环境变量中获取版本号
version_name = os.getenv('GITHUB_REF_NAME', 'v1.0.0.alpha') # 如果环境变量中没有设置版本号,则使用默认值'1.0.0'


block_cipher = None

a = Analysis(
['main.py'],
pathex=['/home/fishros/github/fishbot_tool/'],
binaries=[],
datas=[('ui\\about.ui', 'ui'),('ui\\main.ui', 'ui'),('ui\\taobao.ui', 'ui'),('ui\\assert\\fishros.jpg', 'ui\\assert'),('ui\\assert\\taobao.jpeg', 'ui\\assert'),],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name=f'FishBot_CT_win_x64',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
# icon='ui\\assert\\fishros.jpg',
)


# replace("ui/main.ui", version_name, "VCODE")


4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyserial
# esptool
pyqt6
requests
10 changes: 5 additions & 5 deletions tool/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ def get_version_data() -> list:



def download_firmware(firmware_path):
def download_firmware(firmware_path,path):
print(f'[提示]检测到固件{firmware_path}在HTTP路径上,开始下载')
response = requests.get(firmware_path, stream=True)
# if response.status_code!=200:
# print(f"[警告]固件下载失败:{response.status_code}")
response.raise_for_status()

filename = os.path.basename(firmware_path)
with open(filename, 'wb') as file:

with open(path, 'wb') as file:
for chunk in response.iter_content(chunk_size=1024):
if chunk:
file.write(chunk)

print(f'[提示]下载完成:{filename}')
return filename
print(f'[提示]下载完成:{path}')
return path

def get_fishbot_control_version():
get_version_data()
Expand Down

0 comments on commit 343af3b

Please sign in to comment.