<s> '''<STR_LIT>''' <EOL> import argparse <EOL> import sys <EOL> import json <EOL> import logging <EOL> import time <EOL> from prelert . engineApiClient import EngineApiClient <EOL> HOST = '<STR_LIT:localhost>' <EOL> PORT = <NUM_LIT> <EOL> BASE_URL = '<STR_LIT>' <EOL> POLL_INTERVAL_SECS = <NUM_LIT:10> <EOL> def setupLogging ( ) : <EOL> '''<STR_LIT>''' <EOL> logging . basicConfig ( level = logging . INFO , format = '<STR_LIT>' ) <EOL> def parseArguments ( ) : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" <EOL> + HOST , default = HOST ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" <EOL> + str ( PORT ) , default = PORT ) <EOL> parser . add_argument ( "<STR_LIT>" , action = '<STR_LIT:store_true>' , help = "<STR_LIT>" <EOL> "<STR_LIT>" , dest = "<STR_LIT>" ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" <EOL> + "<STR_LIT>" , type = float , default = <NUM_LIT:0.0> ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" <EOL> + "<STR_LIT>" , type = float , default = <NUM_LIT:0.0> ) <EOL> parser . add_argument ( "<STR_LIT>" , help = "<STR_LIT>" , default = "<STR_LIT:0>" ) <EOL> return parser . parse_args ( ) <EOL> def printHeader ( ) : <EOL> print "<STR_LIT>" <EOL> def printBuckets ( buckets ) : <EOL> for bucket in buckets : <EOL> print "<STR_LIT>" . format ( bucket [ '<STR_LIT>' ] , bucket [ '<STR_LIT>' ] , <EOL> bucket [ '<STR_LIT>' ] ) <EOL> def main ( ) : <EOL> setupLogging ( ) <EOL> args = parseArguments ( ) <EOL> job_id = args . jobid <EOL> engine_client = EngineApiClient ( args . host , BASE_URL , args . port ) <EOL> logging . info ( "<STR_LIT>" + job_id ) <EOL> ( http_status_code , response ) = engine_client . getAllBuckets ( job_id , <EOL> include_records = False , <EOL> anomaly_score_filter_value = args . anomalyScore , <EOL> normalized_probability_filter_value = args . normalizedProbability ) <EOL> if http_status_code != <NUM_LIT:200> : <EOL> print ( http_status_code , json . dumps ( response ) ) <EOL> return <EOL> printHeader ( ) <EOL> printBuckets ( response ) <EOL> if args . continue_poll : <EOL> if len ( response ) > <NUM_LIT:0> : <EOL> next_bucket_id = int ( response [ - <NUM_LIT:1> ] [ '<STR_LIT:id>' ] ) + <NUM_LIT:1> <EOL> else : <EOL> next_bucket_id = None <EOL> while True : <EOL> time . sleep ( POLL_INTERVAL_SECS ) <EOL> ( http_status_code , response ) = engine_client . getBucketsByDate ( job_id = job_id , <EOL> start_date = str ( next_bucket_id ) , end_date = None , <EOL> include_records = False , <EOL> anomaly_score_filter_value = args . anomalyScore , <EOL> normalized_probability_filter_value = args . normalizedProbability ) <EOL> if http_status_code != <NUM_LIT:200> : <EOL> print ( http_status_code , json . dumps ( response ) ) <EOL> break <EOL> printBuckets ( response ) <EOL> if len ( response ) > <NUM_LIT:0> : <EOL> next_bucket_id = int ( response [ - <NUM_LIT:1> ] [ '<STR_LIT:id>' ] ) + <NUM_LIT:1> <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
