Skip to content

Commit b21e91d

Browse files
committed
【完善】:zip 软件包安装逻辑
1 parent 6da3cf7 commit b21e91d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

cmds/cmd_package.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,16 @@ def install_pkg(env_root, bsp_root, pkg):
349349
print("The archive package is broken.")
350350
ret = False
351351
return ret
352-
352+
353353
# unpack package
354354
if not os.path.exists(pkg_dir):
355-
package.unpack(pkg_fullpath, bsp_pkgs_path, pkg, pkgs_name_in_json)
356-
ret = True
355+
try:
356+
if not package.unpack(pkg_fullpath, bsp_pkgs_path, pkg, pkgs_name_in_json):
357+
ret = False
358+
except Exception, e:
359+
os.remove(pkg_fullpath)
360+
ret = False
361+
print('e.message: %s\t' % e.message)
357362

358363
return ret
359364

@@ -641,7 +646,7 @@ def error_packages_handle(error_packages_list, read_back_pkgs_json, pkgs_fn):
641646
if len(error_packages_redownload_error_list):
642647
print("%s" % error_packages_redownload_error_list)
643648
print ("Packages:%s,%s redownloed error,you need to use <pkgs --update> command again to redownload them." %
644-
pkg['name'], pkg['ver'])
649+
(pkg['name'], pkg['ver']))
645650
write_back_pkgs_json = sub_list(
646651
read_back_pkgs_json, error_packages_redownload_error_list)
647652
read_back_pkgs_json = write_back_pkgs_json

package.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,11 @@ def download(self, ver, path, url_from_srv):
223223

224224
def unpack(self, fullpkg_path, path, pkg, pkgs_name_in_json):
225225
try:
226+
# ignore the return value
226227
archive.unpack(fullpkg_path, path, pkg, pkgs_name_in_json)
228+
return True
227229
except Exception, e:
228230
print('e.message:%s\t' % e.message)
229231
print('unpack %s failed' % os.path.basename(fullpkg_path))
232+
os.remove(fullpkg_path)
233+
return False

0 commit comments

Comments
 (0)