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.'
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.'
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."
def main(args): force = '--force' in args prev_data = get_prev_db_data() new_data = get_db_data() if not force and prev_data and prev_data['checksum'] == new_data['checksum']: print('No update necessary') return 0 set_db_data(new_data) if '--no-upload' in args: return 0 res = upload_db_data(new_data) # TODO decide if we should do this here or as a separate process # keeping some number of these around could be good for research # if res == 0 and prev_data: # remove old db file # delete_s3_obj(prev_data['file_name']) return res
def main(args): force = '--force' in args prev_data = get_prev_db_data() new_data = get_db_data() if not force and prev_data and prev_data['checksum'] == new_data[ 'checksum']: print('No update necessary') return 0 set_db_data(new_data) if '--no-upload' in args: return 0 res = upload_db_data(new_data) # TODO decide if we should do this here or as a separate process # keeping some number of these around could be good for research # if res == 0 and prev_data: # remove old db file # delete_s3_obj(prev_data['file_name']) return res