def generate_entry(data_dir, last_sequence, last_timestamp): current_sequence, current_timestamp = get_current_replication_info() log(" last: %d at %s" % (last_sequence, last_timestamp)) log("current: %s at %s" % (current_sequence, current_timestamp)) if last_sequence == current_sequence: log("Replication sequence unchanged, no new data to process.") return None data = get_changed_ids(last_timestamp, current_timestamp) data = json.dumps({ 'data' : data, 'timestamp' : current_timestamp, 'sequence' : current_sequence }) save_data(data_dir, current_sequence, current_timestamp, data) save_state_data(current_sequence, current_timestamp) save_header_html(data_dir) save_copying(data_dir) save_robots_txt(data_dir) save_latest_files(data_dir, current_sequence) log("changed mbid processing complete")
def generate_entry(data_dir, last_sequence, last_timestamp): try: conn = psycopg2.connect(PG_CONNECT) except psycopg2.OperationalError as err: print "Cannot connect to database: %s" % err sys.exit(-1) cur = conn.cursor() cur.execute("select current_replication_sequence, last_replication_date from replication_control"); row = cur.fetchone() current_sequence = row[0] current_timestamp = str(row[1]) print " last: %d at %s\ncurrent: %s at %s\n" % (last_sequence, last_timestamp, current_sequence, current_timestamp) if last_sequence == current_sequence: print "Replication sequence unchanged, no new data to process." return None data = get_changed_ids(last_timestamp, current_timestamp) data = json.dumps({ 'data' : data }) #, sort_keys=True, indent=4) save_data(data_dir, current_sequence, current_timestamp, data)