Skip to content

Commit 733484a

Browse files
committed
【完善】:当软件包连不上网络或者更新出现错误时完善提示信息
1 parent c4d4197 commit 733484a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

cmds/cmd_package.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,9 @@ def install_pkg(env_root, bsp_root, pkg):
262262
ver_sha = get_ver_sha
263263

264264
upstream_change_flag = True
265-
266265
except Exception, e:
267266
# print('e.message:%s\t' % e.message)
268-
print("Failed to obtain mirror url, package will be downloaded from non-mirror server.")
267+
print("Failed to connect to the mirror server, package will be downloaded from non-mirror server.")
269268

270269
if package_url[-4:] == '.git':
271270

@@ -459,18 +458,22 @@ def update_latest_packages(pkgs_fn, bsp_packages_path):
459458
repo_path = os.path.join(bsp_packages_path, pkgs_name_in_json)
460459
repo_path = get_pkg_folder_by_orign_path(repo_path, pkg['ver'])
461460

462-
# If mirror acceleration is enabled, get the update address from
463-
# the mirror server.
464-
if os.path.isfile(env_config_file) and find_macro_in_config(env_config_file, 'SYS_PKGS_DOWNLOAD_ACCELERATE'):
465-
payload_pkgs_name_in_json = pkgs_name_in_json.encode("utf-8")
461+
try:
462+
# If mirror acceleration is enabled, get the update address from
463+
# the mirror server.
464+
if os.path.isfile(env_config_file) and find_macro_in_config(env_config_file, 'SYS_PKGS_DOWNLOAD_ACCELERATE'):
465+
payload_pkgs_name_in_json = pkgs_name_in_json.encode("utf-8")
466466

467-
# Change repo's upstream address.
468-
mirror_url = get_url_from_mirror_server(
469-
payload_pkgs_name_in_json, pkg['ver'])
467+
# Change repo's upstream address.
468+
mirror_url = get_url_from_mirror_server(
469+
payload_pkgs_name_in_json, pkg['ver'])
470470

471-
if mirror_url[0] != None:
472-
cmd = 'git remote set-url origin ' + mirror_url[0]
473-
git_cmd_exec(cmd, repo_path)
471+
if mirror_url[0] != None:
472+
cmd = 'git remote set-url origin ' + mirror_url[0]
473+
git_cmd_exec(cmd, repo_path)
474+
475+
except Exception, e:
476+
print("Failed to connect to the mirror server, using non-mirror server to update.")
474477

475478
# Update the package repository from upstream.
476479
cmd = 'git pull'

package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ def download(self, ver, path, url_from_srv):
230230
break
231231
except Exception, e:
232232
#print url_from_srv
233-
print('e.message:%s\t' % e.message)
233+
# print('e.message:%s\t' % e.message)
234234
retryCount = retryCount + 1
235235
if retryCount > 5:
236-
print('%s download fail!' % path)
236+
print('%s download fail!\n' % path.decode("gbk").encode("utf-8"))
237237
if os.path.isfile(path):
238238
os.remove(path)
239239
return False

0 commit comments

Comments
 (0)