|
13 | 13 | # 将git目录添加到datas参数中,换一台机器还是找不到git,转而从gitee下载git_min.zip,并解压到当前目录下,这样就可以避免在打包成exe后,找不到git可执行文件的问题 |
14 | 14 | # 3. Pyinstaller download_from_git.py --onefile --name hutb_downloader -i hutb_log.ico |
15 | 15 | # |
| 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 | +# |
16 | 22 | # |
17 | 23 | # 其他(开发过程): |
18 | 24 | # 使用.spec文件打包:Pyinstaller hutb_downloader.spec |
|
68 | 74 | print("Using git executable: ", git_path) |
69 | 75 | os.environ['GIT_PYTHON_GIT_EXECUTABLE'] = git_path |
70 | 76 |
|
| 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 | + |
71 | 81 |
|
72 | 82 | import time |
73 | 83 | import zipfile |
@@ -219,6 +229,7 @@ def merge_files(input_dir, output_file): |
219 | 229 | files.sort() |
220 | 230 |
|
221 | 231 | with open(output_file, 'wb') as out: |
| 232 | + print("Merging files into: ", output_file) |
222 | 233 | for file_name in files: |
223 | 234 | print("Merging file: ", file_name) |
224 | 235 | file_path = os.path.join(input_dir, file_name) |
@@ -326,7 +337,15 @@ def kill_process_on_port(port): |
326 | 337 | if os.path.exists( local_path ): |
327 | 338 | # Remove previous download folder |
328 | 339 | 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 | + |
330 | 349 |
|
331 | 350 | # 移除工程中不相关的文件 |
332 | 351 | if os.path.exists( os.path.join(local_path, '.git') ): |
@@ -372,7 +391,11 @@ def kill_process_on_port(port): |
372 | 391 | cost_time = datetime.datetime.now() - start |
373 | 392 | # 当网络带宽足够大时,下载时间大约4-5分钟左右 |
374 | 393 | 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() |
376 | 399 | # kill_process_on_port(2000) # 下载完成后自动启动CarlaUE4.exe,方便用户查看下载结果 |
377 | 400 | # if os.path.exists( os.path.join(local_path, 'CarlaUE4.exe') ): |
378 | 401 | # os.system("start "" %s" % os.path.join(local_path, 'CarlaUE4.exe')) # 启动CarlaUE4.exe |
|
0 commit comments