Skip to content

Commit

Permalink
renamed iped_dated_coords to tile_log_records
Browse files Browse the repository at this point in the history
  • Loading branch information
ambientlight committed May 10, 2017
1 parent 2ca05fe commit 8e4e864
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tilequeue/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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')"
Expand Down
6 changes: 3 additions & 3 deletions tilequeue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down

0 comments on commit 8e4e864

Please sign in to comment.