def _import_entity_with_files_and_parameters( self, res_local, res_remote, root_folder, entity_type="entity", skip_conflict_detection=False): files_to_upload = res_local.files_f params_to_upload = res_local.parameters_f if self._update_existing and res_remote is not None: try: user = getpass.getuser() except: user = "******" pass export = Export(True) if entity_type == "application": export.export_application(res_remote, "/tmp/" + user + "/comodit-client/" + res_remote.name, backup=True) elif entity_type == "distribution": export.export_distribution( res_remote, "/tmp/" + user + "/comodit-client/" + res_remote.name, backup=True) elif entity_type == "platform": export.export_platform(res_remote, "/tmp/" + user + "/comodit-client/" + res_remote.name, backup=True) self._delete_old_files(res_remote, files_to_upload, entity_type) self._delete_old_params(res_remote, params_to_upload, entity_type) conflict = self._detect_conflict(res_local, skip_conflict_detection) if conflict: for res_file in res_local.files_f: self._import_entity_and_detect_conflict( res_file, "file", skip_conflict_detection) for param in res_local.parameters_f: self._import_entity_and_detect_conflict( param, "parameter", skip_conflict_detection) self._import_entity(res_local, conflict, entity_type) # Push files' content for f in files_to_upload: file_name = f.name content_file = os.path.join(root_folder, "files", file_name) self._import_file_content(conflict, content_file, res_local, file_name, entity_type) if os.path.exists(os.path.join(root_folder, "thumb")): thumb_file = os.path.join(root_folder, "thumb") self._import_thumbnail(conflict, thumb_file, res_local, entity_type)
def _export(self, argv): self._options = globals.options dist = self._get_entity(argv) root_folder = dist.name if len(argv) > 2: root_folder = argv[2] export = Export(globals.options.force) export.export_distribution(dist, root_folder)
def export(self, opts): if opts.path is None: raise Exception("You must provide the path to the output folder") export = Export(opts.force) export.export_distribution(self._entity, opts.path)