INNER CODE UNIT · Python

create_symlink_job

kblin/ncbi-genome-download · ncbi_genome_download/core.py:652

def create_symlink_job(directory, checksums, filetype, symlink_path):
    """Create a symlink-creating DownloadJob for an already downloaded file."""
    pattern = NgdConfig.get_fileending(filetype)
    filename, _ = get_name_and_checksum(checksums, pattern)
    local_file = os.path.join(directory, filename)
    full_symlink = os.path.join(symlink_path, filename)
    return DownloadJob(None, local_file, None, full_symlink)


def save_and_check(response, local_file, expected_checksum):
    """Save the content of an http response and verify the checksum matches."""
    logger = logging.getLogger("ncbi-genome-download")
    with open(local_file, 'wb') as handle:
        for chunk in response.iter_content(4096):
            handle.write(chunk)

    actual_checksum = md5sum(local_file)
    if actual_checksum != expected_checksum:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…