def _unzip_archive(latest_data): try: runp(['unzip', latest_data['archive_name']], cwd=PATHS['tmp-dir'], check=True) except Exception as err: raise UpdateError(f'... Unable to unzip archive ({err})') print_success(n('... Done.'))
def _do_imports(): """Import new gtfs data into app database """ modifier = '' if VERBOSE else ' --no-verbose' try: runp(f'./import_gtfs{modifier}', shell=True, cwd='./', check=True) except CalledProcessError as err: raise UpdateError(f'... Problem importing archive ({err})') print_success(n('... Done.'))
def set_archive_current(path_to_archive): filename = extract_filename_from_path(path_to_archive) try: runp(f'rm -rf {PATHS["current-dir"]}/*', shell=True, check=True) runp(['cp', path_to_archive, PATHS["current-dir"]], check=True) runp(['unzip', '-q', filename], cwd=PATHS["current-dir"], check=True) runp(f'rm {filename}', shell=True, cwd=PATHS["current-dir"], check=True) runp(f"echo '{filename}' > current", cwd=PATHS["current-dir"], check=True, shell=True) except Exception as err: raise Exception(f'Unable to copy archive to current dir: {err}')
def store_archive(path_to_archive): try: runp(['cp', path_to_archive, PATHS["archives-dir"]], check=True) except Exception as err: raise Exception(f'Unable to copy to archive dir: {err}')
def cleanup_tmp_files(): runp('rm -rf ./tmp/*', shell=True, cwd=IMPORTS_ROOT_DIR)
def _use_archive(archived_file): try: runp(['cp', archived_file, PATHS['tmp-dir']], check=True) except CalledProcessError as err: raise UpdateError(f'... Unable to use local archive ({err})')