Add exception handling for lxc-pack
This commit is contained in:
parent
b3cde0cdc8
commit
528e676d4d
@ -24,8 +24,11 @@ def pack(meta_file):
|
|||||||
xz_path = '{}.xz'.format(tar_path)
|
xz_path = '{}.xz'.format(tar_path)
|
||||||
|
|
||||||
# Remove old package
|
# Remove old package
|
||||||
|
try:
|
||||||
os.unlink(tar_path)
|
os.unlink(tar_path)
|
||||||
os.unlink(xz_path)
|
os.unlink(xz_path)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# Create archive
|
# Create archive
|
||||||
print('Archiving', meta['lxcpath'])
|
print('Archiving', meta['lxcpath'])
|
||||||
@ -41,9 +44,11 @@ def pack(meta_file):
|
|||||||
print('Registering package')
|
print('Registering package')
|
||||||
packages = {}
|
packages = {}
|
||||||
packages_file = os.path.join(BUILD_ROOT, 'packages')
|
packages_file = os.path.join(BUILD_ROOT, 'packages')
|
||||||
if os.path.exists(packages_file):
|
try:
|
||||||
with open(packages_file, 'r') as fd:
|
with open(packages_file, 'r') as fd:
|
||||||
packages = json.load(fd)
|
packages = json.load(fd)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
packages[pkg_name] = meta
|
packages[pkg_name] = meta
|
||||||
with open(packages_file, 'w') as fd:
|
with open(packages_file, 'w') as fd:
|
||||||
json.dump(packages, fd, sort_keys=True, indent=4)
|
json.dump(packages, fd, sort_keys=True, indent=4)
|
||||||
|
Loading…
Reference in New Issue
Block a user