bug 1085: generate package at package parent folder 99/8999/4
authortierno <alfonso.tiernosepulveda@telefonica.com>
Mon, 20 Apr 2020 16:25:41 +0000 (16:25 +0000)
committerbeierlm <mark.beierl@canonical.com>
Tue, 16 Jun 2020 13:25:42 +0000 (15:25 +0200)
Change-Id: I9adf7a43107af939b4a9dccef7e47c3061daf49e
Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
osmclient/common/package_tool.py
osmclient/scripts/osm.py

index c2e1995..19b1386 100644 (file)
@@ -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):
         """
index 402a09b..0523207 100755 (executable)
@@ -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)