<s> import time <EOL> import datetime <EOL> from pappyproxy import http <EOL> from twisted . internet import defer <EOL> """<STR_LIT>""" <EOL> update_queries = [ <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" , <EOL> ] <EOL> drop_queries = [ <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ] <EOL> @ defer . inlineCallbacks <EOL> def update ( dbpool ) : <EOL> for query in update_queries : <EOL> yield dbpool . runQuery ( query ) <EOL> reqrows = yield dbpool . runQuery ( <EOL> """<STR_LIT>""" , <EOL> ) <EOL> new_times = [ ] <EOL> for row in reqrows : <EOL> reqid = row [ <NUM_LIT:0> ] <EOL> if row [ <NUM_LIT:1> ] : <EOL> start_datetime = datetime . datetime . strptime ( row [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> start_unix_time = time . mktime ( start_datetime . timetuple ( ) ) <EOL> else : <EOL> start_unix_time = None <EOL> if row [ <NUM_LIT:2> ] : <EOL> end_datetime = datetime . datetime . strptime ( row [ <NUM_LIT:2> ] , "<STR_LIT>" ) <EOL> end_unix_time = time . mktime ( end_datetime . timetuple ( ) ) <EOL> else : <EOL> end_unix_time = None <EOL> new_times . append ( ( reqid , start_unix_time , end_unix_time ) ) <EOL> for reqid , start_unix_time , end_unix_time in new_times : <EOL> yield dbpool . runQuery ( <EOL> """<STR_LIT>""" , ( start_unix_time , end_unix_time , reqid ) <EOL> ) <EOL> for query in drop_queries : <EOL> yield dbpool . runQuery ( query ) <EOL> yield dbpool . runQuery ( <EOL> """<STR_LIT>""" <EOL> ) </s>
