<s> import time <EOL> import sys <EOL> import random <EOL> from pyonep . datastore import Datastore <EOL> import json <EOL> cik = "<STR_LIT>" <EOL> dataport_config = { <EOL> '<STR_LIT>' : '<STR_LIT:string>' , <EOL> '<STR_LIT>' : [ [ '<STR_LIT>' , <NUM_LIT:1> ] , [ '<STR_LIT>' , <NUM_LIT:2> ] ] , <EOL> '<STR_LIT:count>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> transport_config = { <EOL> '<STR_LIT:host>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT:url>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:3> <EOL> } <EOL> datastore_config = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT:3> , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> interval = <NUM_LIT:3> <EOL> def caseCreateDataport ( ) : <EOL> print "<STR_LIT>" <EOL> reporter = Datastore ( cik , <EOL> interval , <EOL> dataport_config , <EOL> datastore_config , <EOL> transport_config ) <EOL> status , message = reporter . createDataport ( <EOL> alias = '<STR_LIT>' , <EOL> format = "<STR_LIT:float>" , <EOL> name = None , <EOL> preprocess = [ [ '<STR_LIT>' , <NUM_LIT:1> ] ] , <EOL> count = <NUM_LIT:10> , <EOL> duration = "<STR_LIT>" , <EOL> visibility = "<STR_LIT>" ) <EOL> def caseWrite ( ) : <EOL> print "<STR_LIT>" <EOL> reporter = Datastore ( cik , <EOL> interval , <EOL> dataport_config , <EOL> datastore_config , <EOL> transport_config ) <EOL> reporter . start ( ) <EOL> val = random . randint ( <NUM_LIT:1> , <NUM_LIT:100> ) <EOL> print "<STR_LIT>" % val <EOL> try : <EOL> reporter . write ( '<STR_LIT>' , val ) <EOL> except ( KeyboardInterrupt , SystemExit ) : <EOL> reporter . stop ( True ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> reporter . stop ( True ) <EOL> def caseRead ( ) : <EOL> print "<STR_LIT>" <EOL> reporter = Datastore ( cik , <EOL> interval , <EOL> dataport_config , <EOL> datastore_config , <EOL> transport_config ) <EOL> reporter . start ( ) <EOL> print "<STR_LIT>" % interval <EOL> time . sleep ( interval ) <EOL> try : <EOL> print "<STR_LIT>" , reporter . read ( '<STR_LIT>' ) <EOL> except ( KeyboardInterrupt , SystemExit ) : <EOL> reporter . stop ( True ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> reporter . stop ( True ) <EOL> def caseRecordOffset ( ) : <EOL> print "<STR_LIT>" <EOL> reporter = Datastore ( cik , <EOL> interval , <EOL> dataport_config , <EOL> datastore_config , <EOL> transport_config ) <EOL> reporter . start ( ) <EOL> print "<STR_LIT>" <EOL> try : <EOL> reporter . record ( '<STR_LIT>' , [ [ - <NUM_LIT:3> , <NUM_LIT:1> ] , [ - <NUM_LIT:2> , <NUM_LIT:2> ] , [ - <NUM_LIT:1> , <NUM_LIT:3> ] ] ) <EOL> except ( KeyboardInterrupt , SystemExit ) : <EOL> reporter . stop ( True ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> reporter . stop ( True ) <EOL> def caseRecord ( ) : <EOL> print "<STR_LIT>" <EOL> reporter = Datastore ( cik , <EOL> interval , <EOL> dataport_config , <EOL> datastore_config , <EOL> transport_config ) <EOL> reporter . start ( ) <EOL> val = random . randint ( <NUM_LIT:1> , <NUM_LIT:100> ) <EOL> print "<STR_LIT>" % val <EOL> try : <EOL> reporter . record ( '<STR_LIT>' , [ [ int ( time . time ( ) ) , val ] ] ) <EOL> except ( KeyboardInterrupt , SystemExit ) : <EOL> reporter . stop ( True ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> reporter . stop ( True ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> level = datastore_config [ '<STR_LIT>' ] <EOL> print "<STR_LIT>" , level <EOL> print <EOL> caseRecord ( ) <EOL> caseRecordOffset ( ) <EOL> caseWrite ( ) <EOL> caseRead ( ) <EOL> caseCreateDataport ( ) </s>
