示例#1
0
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.'))
示例#2
0
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.'))
示例#3
0
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}')
示例#4
0
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}')
示例#5
0
def cleanup_tmp_files():
    runp('rm -rf ./tmp/*', shell=True, cwd=IMPORTS_ROOT_DIR)
示例#6
0
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})')