From 528e676d4d1fd58980d27c7aaf98e007b16098c0 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Tue, 2 Oct 2018 13:10:24 +0200 Subject: [PATCH] Add exception handling for lxc-pack --- zz-extra/lxc-pack | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zz-extra/lxc-pack b/zz-extra/lxc-pack index 0026676..8bc2740 100755 --- a/zz-extra/lxc-pack +++ b/zz-extra/lxc-pack @@ -24,8 +24,11 @@ def pack(meta_file): xz_path = '{}.xz'.format(tar_path) # Remove old package - os.unlink(tar_path) - os.unlink(xz_path) + try: + os.unlink(tar_path) + os.unlink(xz_path) + except: + pass # Create archive print('Archiving', meta['lxcpath']) @@ -41,9 +44,11 @@ def pack(meta_file): print('Registering package') packages = {} packages_file = os.path.join(BUILD_ROOT, 'packages') - if os.path.exists(packages_file): + try: with open(packages_file, 'r') as fd: packages = json.load(fd) + except: + pass packages[pkg_name] = meta with open(packages_file, 'w') as fd: json.dump(packages, fd, sort_keys=True, indent=4)