示例#1
0
def main(args):
    force = '--force' in args
    ignore_git = '--ignore-git' in args
    db_info = download_db_info()
    if not db_info:
        return 'ERROR: Could not get database info'

    if not force:
        prev_data = get_prev_db_data()
        if prev_data and prev_data['checksum'] == db_info['checksum']:
            print('Checksums match. No update required.')
            return 0

        if prev_data and prev_data['updated'] > db_info['updated']:
            print('Remote database older than local. No update required.')
            return 0

        if not ignore_git:
            git_sha = get_git_sha()
            if git_sha != db_info['git_sha']:
                print('Git hashes do not match. No update required.')
                return 0

    new_db_file = db_info['file_name']
    download_db_file(new_db_file)
    checksum = get_db_checksum(new_db_file)
    if checksum == db_info['checksum']:
        update_live_db_file(new_db_file)
        set_db_data(db_info)
        print('Database successfully updated')
        return 0

    os.remove(new_db_file)
    return 'ERROR: Checksums do not match. Bad db download. Aborting.'
示例#2
0
def main(args):
    force = '--force' in args
    ignore_git = '--ignore-git' in args
    db_info = download_db_info()
    if not db_info:
        return 'ERROR: Could not get database info'

    if not force:
        prev_data = get_prev_db_data()
        if prev_data and prev_data['checksum'] == db_info['checksum']:
            print('Checksums match. No update required.')
            return 0

        if prev_data and prev_data['updated'] > db_info['updated']:
            print('Remote database older than local. No update required.')
            return 0

        if not ignore_git:
            git_sha = get_git_sha()
            if git_sha != db_info['git_sha']:
                print('Git hashes do not match. No update required.')
                return 0

    new_db_file = db_info['file_name']
    new_db_file = f'{DATA_PATH}/{new_db_file}'
    download_db_file(new_db_file)
    checksum = get_db_checksum(new_db_file)
    if checksum == db_info['checksum']:
        update_live_db_file(new_db_file)
        set_db_data(db_info)
        print('Database successfully updated')
        return 0

    os.remove(new_db_file)
    return 'ERROR: Checksums do not match. Bad db download. Aborting.'
示例#3
0
def main(args):
    force = "--force" in args
    ignore_git = "--ignore-git" in args
    db_info = download_db_info()
    if not db_info:
        return "ERROR: Could not get database info"

    if not force:
        prev_data = get_prev_db_data()
        if prev_data and prev_data["checksum"] == db_info["checksum"]:
            print("Checksums match. No update required.")
            return 0

        if prev_data and prev_data["updated"] > db_info["updated"]:
            print("Remote database older than local. No update required.")
            return 0

        if not ignore_git:
            git_sha = get_git_sha()
            if git_sha != db_info["git_sha"]:
                print("Git hashes do not match. No update required.")
                return 0

    new_db_file = db_info["file_name"]
    new_db_file = f"{DATA_PATH}/{new_db_file}"
    download_db_file(new_db_file)
    checksum = get_db_checksum(new_db_file)
    if checksum == db_info["checksum"]:
        update_live_db_file(new_db_file)
        set_db_data(db_info)
        print("Database successfully updated")
        return 0

    os.remove(new_db_file)
    return "ERROR: Checksums do not match. Bad db download. Aborting."
示例#4
0
def get_db_data():
    return {
        "updated": time(),
        "checksum": get_db_checksum(),
        "git_sha": get_git_sha(),
        "file_name": get_db_file_name(),
    }
示例#5
0
def get_db_data():
    return {
        'updated': time(),
        'checksum': get_db_checksum(),
        'git_sha': get_git_sha(),
        'file_name': get_db_file_name(),
    }
示例#6
0
def get_db_data():
    return {
        'updated': time(),
        'checksum': get_db_checksum(),
        'git_sha': get_git_sha(),
        'file_name': get_db_file_name(),
    }
示例#7
0
def get_db_file_name():
    git_sha = get_git_sha()
    checksum = get_db_checksum()
    return f"{git_sha[:10]}-{checksum[:10]}.db"
示例#8
0
def get_db_file_name():
    git_sha = get_git_sha()
    checksum = get_db_checksum()
    return '{}-{}.db'.format(git_sha[:10], checksum[:10])
示例#9
0
def get_db_file_name():
    git_sha = get_git_sha()
    checksum = get_db_checksum()
    return '{}-{}.db'.format(git_sha[:10], checksum[:10])