def extract(self, archive_path: str, extract_path: str) -> None: SUDO.file_assert(archive_path) extract_temp = make_temp_path("zip-extract-temp") SUDO.folder_ensure(extract_temp) zipper = CmdUnZip() zipper.with_archive(archive_path) zipper.with_extract(extract_temp) zipper.execute_unit_sert() SUDO.files_move(extract_temp, extract_path)
def archive(self, archive_path: str, extract_path: str) -> None: SUDO.folder_assert(extract_path) archive_temp = make_temp_path("zip-archive-temp") SUDO.parent_ensure(archive_temp) zipper = CmdZip() zipper.with_archive(archive_temp) zipper.with_extract(extract_path) zipper.execute_unit_sert() SUDO.files_move(archive_temp, archive_path)
def extract(self, archive_path: str, extract_path: str) -> None: SUDO.file_assert(archive_path) extract_temp = make_temp_path("zip-extract-temp") SUDO.folder_ensure(extract_temp) tar = Tar() tar.with_archive(archive_path) tar.with_extract(extract_temp) tar.with_packer(archive_path) tar.with_make_unpack() # keep last tar.execute_unit_sert() SUDO.files_move(extract_temp, extract_path)
def archive(self, archive_path: str, extract_path: str) -> None: logger.debug(f"pack.archive.tar: {extract_path}") SUDO.folder_assert(extract_path) archive_temp = make_temp_path("tar-archive-temp") SUDO.parent_ensure(archive_temp) tar = Tar() tar.with_archive(archive_temp) tar.with_extract(extract_path) tar.with_packer(archive_path) tar.with_make_pack() # keep last tar.execute_unit_sert() SUDO.files_move(archive_temp, archive_path) synchronize_header(extract_path, archive_path)
def invoke_fetch(self, effect: token.FetchEffect) -> None: remote_url = effect.url package_name = os.path.basename(remote_url) fetch_archive = make_temp_path('fetch-archive') + '-' + package_name fetch_extract = make_temp_path('fetch-extract') + '-' + package_name # download transport = transport_provider(remote_url) transport.get(fetch_archive, remote_url) # extract packer = packer_provider(remote_url) packer.extract(fetch_archive, fetch_extract) # move source_path = fetch_extract + '/' + effect.source target_path = self.runtime_path(effect.target) SUDO.files_move(source_path, target_path) # clean SUDO.files_delete(fetch_archive) SUDO.files_delete(fetch_extract)
def extract(self, archive_path: str, extract_path: str) -> None: logger.debug(f"pack.extract.tar: {extract_path}") SUDO.file_assert(archive_path) extract_temp = make_temp_path("tar-extract-temp") SUDO.folder_ensure(extract_temp) tar = Tar() tar.with_archive(archive_path) tar.with_extract(extract_temp) tar.with_packer(archive_path) tar.with_make_unpack() # keep last tar.execute_unit_sert() if SUDO.folder_check(extract_path): # user rsync to preserve active machines SUDO.files_sync_full(extract_temp, extract_path) SUDO.files_delete(extract_temp) else: # user move for efficiency SUDO.files_move(extract_temp, extract_path) synchronize_header(archive_path, extract_path)
def get(self, local_url: str, remote_url: str) -> None: "fetch remote resource and persist headers in xattr" logger.debug(f"http.get.fetch: {remote_url}") local, remote = self.parse(local_url, remote_url) header_path = make_temp_path("curl-head") source_path = make_temp_path("curl-gets") target_path = local.path SUDO.parent_ensure(header_path) curl = Curl() with_auth_url(curl, remote_url) with_proxy_config(curl, remote_url) curl.with_file_get(source_path) curl.with_dump_header(header_path) curl.execute_unit_sert() header_dict = parse_header_file(header_path) SUDO.files_delete(header_path) SUDO.files_move(source_path, target_path) # TODO attr SUDO.xattr_save(target_path, header_dict)
def perform_image_move(source: ImageStore, target: ImageStore) -> None: if source.has_archive(): SUDO.files_move(source.archive_path(), target.archive_path()) if source.has_extract(): SUDO.files_move(source.extract_path(), target.extract_path())