def try_audit(file_path, web3_req=False, contrat_address=False): contract_object = disassmbly_contract(file_path) contract_init_code, contract_runtime_code = split_contract_code( contract_object) #contract_init_code.print_code() temp_file = './temp/code.txt' code_temp_file = open(temp_file, 'w') code_temp_file.write(contract_runtime_code.get_all_code()) code_temp_file.close() state_object = context.state_object(web3_req, contrat_address) ''' if contract_init_code : contract_init_code_executor = executor.executor(contract_init_code,state_object,context.execute_context()) contract_init_code_executor.run() ''' contract_runtime_code_executor = executor.executor( contract_runtime_code, state_object, context.execute_context(), contrat_address) contract_runtime_code_executor.run() branches_count = contract_runtime_code_executor.get_execute_branch_count( ) #contract_init_code_executor.get_execute_branch_count() + \ instrutments_count = contract_runtime_code_executor.get_execute_instrutment_count( ) #contract_init_code_executor.get_execute_instrutment_count() + \ print '\033[1;32mExecuting Branches :', branches_count, '\033[0m' print '\033[1;32mExecuting Instrutments :', instrutments_count, '\033[0m' print ''
def main(): with open('configv2.json', 'r') as file: data = json.loads(file.read()) raspi = {} for key, value in data["raspi"].items(): raspi.update({key: value}) internet_check(raspi["mqtt_url"]) logging.basicConfig(filename="error.log") sensor_list = [] for listed_sensor in raspi["sensors"]: sensor_list.append( executor( sensor_object(raspi["mqtt_url"], listed_sensor).process, raspi["frequency"])) processes = [] try: for sensor in sensor_list: process = Process(target=sensor.execute) process.start() processes.append(process) for process in processes: process.join() processes.remove(process) except Exception as e: logging.error(traceback.format_exc())
def req_executor(self, value): num = value['number'] # host = value['host'] # port = value['port'] # self.appId = value['app_id'] elist = [] for i in range(0, num): ex = executor.executor(self.exeid, value['app_id'], self.exeLock) self.executors.append(ex) self.executors_status.append(ex.status) idmsg = { 'id': self.exeid, 'status': ex.status, 'app_id': value['app_id'] } elist.append(idmsg) self.exeid -= 1 msg = { 'id': self.workerid, 'host': self.config['worker_host'], 'port': self.config['worker_port'], 'list': elist } wrapmsg = self.wrap_msg(self.config['master_host'], self.config['master_port'], 'update_executors', msg) self.listener.sendMessage(wrapmsg)
def template(fn,*args,**kwargs): path = None if type(args) is tuple and args.__len__() == 0: path = kwargs.get("file","unknown.html") is_public = kwargs.get("is_public",False) else: path =args[0] instance = executor.executor(fn,path) return instance.execute_request(True)
def __init__(self): # TODO: need some way to remove old invoke id ,say, after some seconds pass self.aggregator_collections = {} self.executor = executor() #setup outgoing sockets to neighbors self.context = zmq.Context() self.senders = {} for neighbor in NEIGHBOR_LIST: self.senders[neighbor] = self.context.socket(zmq.PUSH) self.senders[neighbor].connect("tcp://{0}:{1}".format(neighbor,DISPATCHER_PORT)) #setup a special outgoing socket to an interface self.senders['localhost'] = self.context.socket(zmq.PUSH) self.senders['localhost'].connect("tcp://{0}:{1}".format('localhost',INTERFACE_PORT))
def __init__(self): # TODO: need some way to remove old invoke id ,say, after some seconds pass self.aggregator_collections = {} self.executor = executor() #setup outgoing sockets to neighbors self.context = zmq.Context() self.senders = {} for neighbor in NEIGHBOR_LIST: self.senders[neighbor] = self.context.socket(zmq.PUSH) self.senders[neighbor].connect("tcp://{0}:{1}".format( neighbor, DISPATCHER_PORT)) #setup a special outgoing socket to an interface self.senders['localhost'] = self.context.socket(zmq.PUSH) self.senders['localhost'].connect("tcp://{0}:{1}".format( 'localhost', INTERFACE_PORT))
def formator(self, options): args = ['show'] service = options[0] logger.debug("=====>>>>>> args before executor call = %s" % args) if service in ['protocols', 'nat', 'interfaces', 'firewall']: args.extend(options) elif service in ['dns', 'dhcp-server', 'ssh', 'webproxy']: options.insert(0, 'service') args.extend(options) else: raise ServiceError('unknown such service!') exe = executor(list(args)) try: #if not exe.checkcmd(' '.join(args)): # logger.error("%s: given args does not match with existing configs!"%args) # return False execstate, output = exe.execmd() logger.debug("=====>>>>>> args after executor call = %s" % args) except OperationFailed, e: logger.error(e.message) return False
def formator(self,options): args=['show'] service = options[0] logger.debug("=====>>>>>> args before executor call = %s"%args) if service in ['protocols','nat','interfaces','firewall']: args.extend(options) elif service in ['dns','dhcp-server','ssh','webproxy']: options.insert(0,'service') args.extend(options) else: raise ServiceError('unknown such service!') exe=executor(list(args)) try: #if not exe.checkcmd(' '.join(args)): # logger.error("%s: given args does not match with existing configs!"%args) # return False execstate,output=exe.execmd() logger.debug("=====>>>>>> args after executor call = %s"%args) except OperationFailed, e: logger.error(e.message) return False
def __init__(self): # TODO: need some way to remove old invoke id ,say, after some seconds pass self.aggregator_collections = {} self.executor = executor() #setup outgoing sockets to neighbors self.context = zmq.Context() self.senders = {} for neighbor in NEIGHBOR_LIST: self.senders[neighbor] = self.context.socket(zmq.PUSH) self.senders[neighbor].connect("tcp://{0}:{1}".format(neighbor,DISPATCHER_PORT)) #setup a special outgoing socket to an interface self.senders['localhost'] = self.context.socket(zmq.PUSH) self.senders['localhost'].connect("tcp://{0}:{1}".format('localhost',INTERFACE_PORT)) self.host = HOST self.host_location = HOST_LOCATION self.host_coverage = HOST_COVERAGE self.nodes = NODES_LIST self.node_locations = NODE_LOCATIONS self.node_distances = NODE_DISTANCES self.node_distance = 86400
from executor import executor executor = executor().run("run", True)
from executor import executor executor = executor().run("dailyWrapUp")