<s> import sys <EOL> from datetime import datetime <EOL> import pytz <EOL> from performanceplatform . collector . piwik . base import BaseFetcher <EOL> from performanceplatform . utils . data_pusher import Pusher <EOL> class Fetcher ( BaseFetcher ) : <EOL> def __init__ ( self , credentials , query ) : <EOL> super ( Fetcher , self ) . __init__ ( credentials , query ) <EOL> self . last_minutes = query . get ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> def _request_params ( self ) : <EOL> params = super ( Fetcher , self ) . _request_params ( ) <EOL> params . update ( { '<STR_LIT>' : self . last_minutes } ) <EOL> return params <EOL> class Parser ( ) : <EOL> def _timestamp ( self ) : <EOL> timezone = pytz . UTC <EOL> timestamp = datetime . now ( timezone ) . replace ( microsecond = <NUM_LIT:0> ) <EOL> return timestamp . isoformat ( ) <EOL> def parse ( self , data ) : <EOL> timestamp = self . _timestamp ( ) <EOL> visitor_count = int ( data [ <NUM_LIT:0> ] [ "<STR_LIT>" ] ) <EOL> return [ { <EOL> "<STR_LIT>" : timestamp , <EOL> "<STR_LIT>" : timestamp , <EOL> "<STR_LIT>" : visitor_count , <EOL> "<STR_LIT>" : "<STR_LIT>" } ] <EOL> def main ( credentials , data_set_config , query , options , start_at , end_at ) : <EOL> if start_at or end_at : <EOL> print '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> data = Fetcher ( credentials , query ) . fetch ( ) <EOL> parsed_data = Parser ( ) . parse ( data ) <EOL> Pusher ( data_set_config , options ) . push ( parsed_data ) </s>
