action='store_true', help="Sets superstar to local superstar.") parser.add_argument("-d", "--dev", action='store_true', help="Sets superstar to test.robotmoose.com.") parser.add_argument("ROBOT", help="Full path of robot.") args = parser.parse_args() #Figure out superstar... superstar_url = args.superstar if args.dev: superstar_url = "test.robotmoose.com" if args.local: superstar_url = "127.0.0.1:8081" ss = superstar.superstar_t(superstar_url) #Check robot if len(ss.pathify(args.ROBOT).split('/')) != 3: raise Exception("Invalid robot name (expect YEAR/SCHOOL/NAME).") #Print errors... def onerror(error): print( str("Error(" + str(error["code"]) + ") - " + error["message"])) exit(1) #Print success... def onsuccess(result): print("Created robot.")
#!/usr/bin/env python3 import json import superstar import sys import time #Experiment variables (you should change only these really...) auth = '' experiment_path = '/test' payload_length = 128 ss = superstar.superstar_t('http://198.199.89.187:8081') total_runs = 1000 #Meh... old_value = '' #Important time points tx_start_time = 0 tx_end_time = 0 #Total averages rx_avg = 0 tx_avg = 0 total_avg = 0 #Called on error, print and die... def err_func(res): sys.stderr.write('\nError - ' + str(res) + '\n') sys.stderr.flush() exit(1)
parser.add_argument("-f","--force", action='store_true', help="Overwrite existing robots (prompts if flag not set).") parser.add_argument("ROBOT", help="Robot to clone.") parser.add_argument("FILE", help="File containing a robots and an authentication on per line of a file.") args=parser.parse_args() #Figure out superstar... superstar_url=args.superstar if args.dev: superstar_url="test.robotmoose.com" if args.local: superstar_url="127.0.0.1:8081" ss=superstar.superstar_t(superstar_url) #Validate clone robot if len(ss.pathify(args.ROBOT).split('/'))!=3: raise Exception("Robot to clone \""+args.ROBOT+"\" is not a valid robot name (expected YEAR/SCHOOL/NAME).") #Check robot file existance if not os.path.isfile(args.FILE): raise Exception("File \""+args.FILE+"\" is not a file.") #Open robot file robot_file=None try: robot_file=open(args.FILE) except Exception: raise Exception("File \""+args.FILE+"\" is not readble.")
#!/usr/bin/env python3 import json import superstar import sys total_runs=1000 #Experiment variables (you should change only these really...) auth='' experiment_path='/test' payload_length=128 ss=superstar.superstar_t('http://198.199.89.187:8081') total_runs=1000 #Called on error, print and die... def err_func(res): sys.stderr.write('\nError - '+str(res)+'\n') sys.stderr.flush() exit(1) #Run when set of initial known value is done... def first_set(res): #Globals in python be lame... global experiment_path global ss #Wait for a change... ss.get_next(experiment_path,ss.sha256(json.dumps('a'*payload_length)),end_rx_func,err_func) #On change, write it (reply if you will) def end_rx_func(res):