Skip to content

Commit 1d76377

Browse files
committed
修复在新机器上下载发行版的问题
1 parent d38daff commit 1d76377

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

Util/download_from_git.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
# 将git目录添加到datas参数中,换一台机器还是找不到git,转而从gitee下载git_min.zip,并解压到当前目录下,这样就可以避免在打包成exe后,找不到git可执行文件的问题
1414
# 3. Pyinstaller download_from_git.py --onefile --name hutb_downloader -i hutb_log.ico
1515
#
16+
#
17+
# 新机器问题:fatal: unable to access 'https://git.code.tencent.com/OpenHUTB/release.git/': error setting certificate verify locations: CAfile: E:/Projects/OpenHUTB-mcp/mcp/git/mingw64/ssl/certs/ca-bundle.crt/etc/ssl/certs/ca-bundle.crt CApath: none
18+
# 解决:git\bin\git.exe config --global http.sslVerify false
19+
#
20+
# 没有拉取大文件:
21+
#
1622
#
1723
# 其他(开发过程):
1824
# 使用.spec文件打包:Pyinstaller hutb_downloader.spec
@@ -68,6 +74,10 @@
6874
print("Using git executable: ", git_path)
6975
os.environ['GIT_PYTHON_GIT_EXECUTABLE'] = git_path
7076

77+
disable_ssl_verify_command = "%s config --global http.sslVerify false" % os.path.join(script_dir, 'git', 'bin', 'git.exe')
78+
print(disable_ssl_verify_command)
79+
os.system(disable_ssl_verify_command) # 解决新机器上git拉取代码时,出现的证书验证问题
80+
7181

7282
import time
7383
import zipfile
@@ -219,6 +229,7 @@ def merge_files(input_dir, output_file):
219229
files.sort()
220230

221231
with open(output_file, 'wb') as out:
232+
print("Merging files into: ", output_file)
222233
for file_name in files:
223234
print("Merging file: ", file_name)
224235
file_path = os.path.join(input_dir, file_name)
@@ -326,7 +337,15 @@ def kill_process_on_port(port):
326337
if os.path.exists( local_path ):
327338
# Remove previous download folder
328339
shutil.rmtree( local_path , onerror=remove_readonly)
329-
repo = GitRepository(local_path, remote_path)
340+
# gitpython 库在新机器下载大文件时会出现问题,改为直接调用 git 命令行工具进行下载
341+
# repo = GitRepository(local_path, remote_path)
342+
# 问题:Skipping object checkout, Git LFS is not installed for this repository.
343+
# 解决:git lfs install
344+
git_path = os.path.join(script_dir, 'git', 'bin', 'git.exe')
345+
clone_cmd = "%s clone %s %s && cd %s & %s lfs install && %s lfs pull && cd .." % (git_path, remote_path, local_path, save_dir, git_path, git_path)
346+
print("Cloning repository with command: ", clone_cmd)
347+
os.system(clone_cmd)
348+
330349

331350
# 移除工程中不相关的文件
332351
if os.path.exists( os.path.join(local_path, '.git') ):
@@ -372,7 +391,11 @@ def kill_process_on_port(port):
372391
cost_time = datetime.datetime.now() - start
373392
# 当网络带宽足够大时,下载时间大约4-5分钟左右
374393
print('Download finished, cost: %s' % (cost_time))
375-
print("Download to: ", local_path)
394+
print("Download path: ", local_path)
395+
396+
print("Press any key to continue...")
397+
print("Launch simulator to click the file: %s" % os.path.join(local_path, 'CarlaUE4.exe'))
398+
input()
376399
# kill_process_on_port(2000) # 下载完成后自动启动CarlaUE4.exe,方便用户查看下载结果
377400
# if os.path.exists( os.path.join(local_path, 'CarlaUE4.exe') ):
378401
# os.system("start "" %s" % os.path.join(local_path, 'CarlaUE4.exe')) # 启动CarlaUE4.exe

Util/hutb_log.ico

1.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)