From b37f724257bb6adfdd8b07b9885c8cff03412db8 Mon Sep 17 00:00:00 2001 From: tierno Date: Mon, 20 Apr 2020 16:25:41 +0000 Subject: [PATCH] bug 1085: generate package at package parent folder Change-Id: I9adf7a43107af939b4a9dccef7e47c3061daf49e Signed-off-by: tierno --- osmclient/common/package_tool.py | 24 +++++++++++++----------- osmclient/scripts/osm.py | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/osmclient/common/package_tool.py b/osmclient/common/package_tool.py index c2e1995..19b1386 100644 --- a/osmclient/common/package_tool.py +++ b/osmclient/common/package_tool.py @@ -370,22 +370,24 @@ class PackageTool(object): with tarfile.open("{}.tar.gz".format(package_name), mode='w:gz') as archive: print("Adding File: {}".format(package_name)) archive.add('{}'.format(package_name), recursive=True) - #return "Created {}.tar.gz".format(package_folder) - #self.build("{}".format(os.path.basename(package_folder))) + # return "Created {}.tar.gz".format(package_folder) + # self.build("{}".format(os.path.basename(package_folder))) os.chdir(cwd) + cwd = None + created_package = "{}/{}.tar.gz".format(os.path.dirname(package_folder) or '.', package_name) + os.rename("{}/{}.tar.gz".format(directory_name, package_name), + created_package) + os.rename("{}/{}/checksums.txt".format(directory_name, package_name), + "{}/checksums.txt".format(package_folder)) + print("Package created: {}".format(created_package)) + return created_package except Exception as exc: + raise ClientException('failure during build of targz file (create temp dir, calculate checksum, ' + 'tar.gz file): {}'.format(exc)) + finally: if cwd: os.chdir(cwd) shutil.rmtree(os.path.join(package_folder, "tmp")) - raise ClientException('failure during build of targz file (create temp dir, calculate checksum, tar.gz file): {}'.format(exc)) - created_package = "{}/{}.tar.gz".format(package_folder, package_name) - os.rename("{}/{}.tar.gz".format(directory_name, package_name), - created_package) - os.rename("{}/{}/checksums.txt".format(directory_name, package_name), - "{}/checksums.txt".format(package_folder)) - shutil.rmtree(os.path.join(package_folder, "tmp")) - print("Package created: {}".format(created_package)) - return created_package def create_temp_dir(self, package_folder, charm_list=None): """ diff --git a/osmclient/scripts/osm.py b/osmclient/scripts/osm.py index 402a09b..0523207 100755 --- a/osmclient/scripts/osm.py +++ b/osmclient/scripts/osm.py @@ -3097,7 +3097,7 @@ def k8scluster_list(ctx, filter, literal): for cluster in resp: table.add_row([cluster['name'], cluster['_id'], cluster['k8s_version'], cluster['vim_account'], json.dumps(cluster['nets']), cluster["_admin"]["operationalState"], - trunc_text(cluster.get('description',''),40)]) + trunc_text(cluster.get('description') or '', 40)]) table.align = 'l' print(table) # except ClientException as e: @@ -3264,7 +3264,7 @@ def repo_list(ctx, filter, literal): table = PrettyTable(['Name', 'Id', 'Type', 'URI', 'Description']) for repo in resp: #cluster['k8s-nets'] = json.dumps(yaml.safe_load(cluster['k8s-nets'])) - table.add_row([repo['name'], repo['_id'], repo['type'], repo['url'], trunc_text(repo.get('description',''),40)]) + table.add_row([repo['name'], repo['_id'], repo['type'], repo['url'], trunc_text(repo.get('description') or '',40)]) table.align = 'l' print(table) -- 2.25.1