diff --git a/tilequeue/command.py b/tilequeue/command.py index ae1ad0f8..0f18ba27 100755 --- a/tilequeue/command.py +++ b/tilequeue/command.py @@ -957,11 +957,11 @@ def tilequeue_consume_tile_traffic(cfg, peripherals): logger = make_logger(cfg, 'consume_tile_traffic') logger.info('Consuming tile traffic logs ...') - iped_dated_coords = None + tile_log_records = None with open(cfg.tile_traffic_log_path, 'r') as log_file: - iped_dated_coords = parse_log_file(log_file) + tile_log_records = parse_log_file(log_file) - if not iped_dated_coords: + if not tile_log_records: logger.info("Couldn't parse log file") sys.exit(1) @@ -978,7 +978,7 @@ def tilequeue_consume_tile_traffic(cfg, peripherals): max_timestamp = cursor.fetchone()[0] n_coords_inserted = 0 - for host, timestamp, coord_int in iped_dated_coords: + for host, timestamp, coord_int in tile_log_records: if not max_timestamp or timestamp > max_timestamp: coord = coord_unmarshall_int(coord_int) cursor.execute("INSERT into tile_traffic_v4 (date, z, x, y, tilesize, service, host) VALUES ('%s', %d, %d, %d, %d, '%s', '%s')" diff --git a/tilequeue/utils.py b/tilequeue/utils.py index a14dbda1..c0caf3e0 100644 --- a/tilequeue/utils.py +++ b/tilequeue/utils.py @@ -35,15 +35,15 @@ def parse_log_file(log_file): log_pattern = '%s - - %s "([\w]+) %s.*' % (ip_pattern, date_pattern, tile_id_pattern) - iped_dated_coords = [] + tile_log_records = [] for log_string in log_file: match = re.search(log_pattern, log_string) if match and len(match.groups()) == 8: - iped_dated_coords.append((match.group(1), + tile_log_records.append((match.group(1), datetime.strptime(match.group(2), '%d/%B/%Y %H:%M:%S'), coord_marshall_int(create_coord(match.group(6), match.group(7), match.group(5))))) - return iped_dated_coords + return tile_log_records def mimic_prune_tiles_of_interest_sql_structure(cursor): cursor.execute('''CREATE TABLE IF NOT EXISTS tile_traffic_v4 (