Beispiel #1
0
 def update(self, venv_id, name, description, source_path):
     result = True
     try:
         data = {}
         need_update = False
         if name:
             data["name"] = name
         if description:
             data["description"] = description
         if os.path.exists(source_path) and os.path.isfile(source_path):
             sha1 = file_sha1sum(source_path)
             data["sha1"] = sha1
             LOG.debug("sha1: %s, %s", sha1, type(sha1))
             venv_path = self.make_venv_version_path(venv_id, sha1)
             if os.path.exists(venv_path):
                 shutil.rmtree(venv_path)
             os.makedirs(venv_path)
             shutil.copy2(source_path, os.path.join(venv_path,
                                                    "venv.tar.gz"))
             os.remove(source_path)
             need_update = True
         if data or need_update:
             success = Venvs.instance().update(venv_id, data)
             if success:
                 if "sha1" in data:
                     description = "" if "description" not in data else data[
                         "description"]
                     VenvHistory.instance().add(venv_id,
                                                data["sha1"],
                                                description=description)
             else:
                 result = False
     except Exception as e:
         LOG.exception(e)
     return result
Beispiel #2
0
 def update(self, app_id, name, description, source_path):
     result = True
     try:
         data = {}
         need_update = False
         if name:
             data["name"] = name
         if description:
             data["description"] = description
         if os.path.exists(source_path) and os.path.isfile(source_path):
             sha1 = file_sha1sum(source_path)
             data["sha1"] = sha1
             LOG.debug("sha1: %s, %s", sha1, type(sha1))
             app_path = self.make_app_version_path(app_id, sha1)
             self.ldfs.delete_directory(app_path)
             self.ldfs.create_file(source_path, os.path.join(app_path, "app.zip"), replica = 1)
             os.remove(source_path)
             need_update = True
         if data or need_update:
             success = Applications.instance().update(app_id, data)
             if success:
                 if "sha1" in data:
                     description = "" if "description" not in data else data["description"]
                     ApplicationHistory.instance().add(app_id, data["sha1"], description = description)
             else:
                 result = False
     except Exception as e:
         LOG.exception(e)
     return result
Beispiel #3
0
 def create(self, name, description, source_path):
     sha1 = file_sha1sum(source_path)
     LOG.debug("sha1: %s, %s", sha1, type(sha1))
     app_id = Applications.instance().add(name, sha1, description = description)
     app_path = self.make_app_version_path(app_id, sha1)
     self.ldfs.delete_directory(app_path)
     self.ldfs.create_file(source_path, os.path.join(app_path, "app.zip"), replica = 1)
     os.remove(source_path)
     ApplicationHistory.instance().add(app_id, sha1, description = description)
     return app_id
Beispiel #4
0
 def create(self, name, description, source_path):
     sha1 = file_sha1sum(source_path)
     LOG.debug("sha1: %s, %s", sha1, type(sha1))
     app_id = Applications.instance().add(name, sha1, description = description)
     app_path = self.make_app_version_path(app_id, sha1)
     if os.path.exists(app_path):
         shutil.rmtree(app_path)
     os.makedirs(app_path)
     shutil.copy2(source_path, os.path.join(app_path, "app.zip"))
     os.remove(source_path)
     ApplicationHistory.instance().add(app_id, sha1, description = description)
     return app_id
Beispiel #5
0
 def create(self, name, description, source_path):
     sha1 = file_sha1sum(source_path)
     LOG.debug("sha1: %s, %s", sha1, type(sha1))
     venv_id = Venvs.instance().add(name, sha1, description=description)
     venv_path = self.make_venv_version_path(venv_id, sha1)
     if os.path.exists(venv_path):
         shutil.rmtree(venv_path)
     os.makedirs(venv_path)
     shutil.copy2(source_path, os.path.join(venv_path, "venv.tar.gz"))
     os.remove(source_path)
     VenvHistory.instance().add(venv_id, sha1, description=description)
     return venv_id
Beispiel #6
0
 def create(self, name, description, source_path):
     sha1 = file_sha1sum(source_path)
     LOG.debug("sha1: %s, %s", sha1, type(sha1))
     venv_id = Venvs.instance().add(name, sha1, description=description)
     venv_path = self.make_venv_version_path(venv_id, sha1)
     self.ldfs.delete_directory(venv_path)
     self.ldfs.create_file(source_path,
                           os.path.join(venv_path, "venv.zip"),
                           replica=1)
     os.remove(source_path)
     VenvHistory.instance().add(venv_id, sha1, description=description)
     return venv_id
Beispiel #7
0
 def create(self, name, description, source_path):
     sha1 = file_sha1sum(source_path)
     LOG.debug("sha1: %s, %s", sha1, type(sha1))
     app_id = Applications.instance().add(name, sha1, description = description)
     app_path = self.make_app_version_path(app_id, sha1)
     if os.path.exists(app_path):
         shutil.rmtree(app_path)
     os.makedirs(app_path)
     shutil.copy2(source_path, os.path.join(app_path, "app.tar.gz"))
     os.remove(source_path)
     if os.path.exists(os.path.join(app_path, "app")):
         shutil.rmtree(os.path.join(app_path, "app"))
     t = tarfile.open(os.path.join(app_path, "app.tar.gz"), "r")
     t.extractall(app_path)
     path_parts = splitall(t.getnames()[0])
     tar_root_name = path_parts[1] if path_parts[0] == "." else path_parts[0]
     t.close()
     os.rename(os.path.join(app_path, tar_root_name), os.path.join(app_path, "app"))
     ApplicationHistory.instance().add(app_id, sha1, description = description)
     return app_id
Beispiel #8
0
 def update(self, app_id, name, description, source_path):
     result = True
     try:
         data = {}
         need_update = False
         if name:
             data["name"] = name
         if description:
             data["description"] = description
         if os.path.exists(source_path) and os.path.isfile(source_path):
             sha1 = file_sha1sum(source_path)
             data["sha1"] = sha1
             LOG.debug("sha1: %s, %s", sha1, type(sha1))
             app_path = self.make_app_version_path(app_id, sha1)
             if os.path.exists(app_path):
                 shutil.rmtree(app_path)
             os.makedirs(app_path)
             shutil.copy2(source_path, os.path.join(app_path, "app.tar.gz"))
             os.remove(source_path)
             if os.path.exists(os.path.join(app_path, "app")):
                 shutil.rmtree(os.path.join(app_path, "app"))
             t = tarfile.open(os.path.join(app_path, "app.tar.gz"), "r")
             t.extractall(app_path)
             tar_root_name = splitall(t.getnames()[0])[0]
             os.rename(os.path.join(app_path, tar_root_name), os.path.join(app_path, "app"))
             need_update = True
         if data or need_update:
             success = Applications.instance().update(app_id, data)
             if success:
                 if "sha1" in data:
                     description = "" if "description" not in data else data["description"]
                     ApplicationHistory.instance().add(app_id, data["sha1"], description = description)
             else:
                 result = False
     except Exception as e:
         LOG.exception(e)
     return result