def put(self, ip): """ 修改任务状态 """ info = self.get_argument('info', '') status = self.get_argument('status', '') if status not in ['checked', 'finished']: self.write("status Failed") self.finish() elif status == 'checked': info_list = info.split(',') info_dict = { 'PBL': info_list[0], 'SBL': info_list[1], 'XBL': info_list[2] } task = Task(self) yield task.change_task_status(ip, status, info_dict) self.write("OK") self.finish() else: task = Task(self) yield task.change_task_status(ip, status, {'info': info}) self.write("OK") self.finish()
def run(self, args): if 'all' in args.guests: args.guests = self.AllGuests boxes = [] for guest in args.guests: boxes.append(BoxInfo(guest, self.root_dir, args)) tasks = self.tasklist('Create Boxes') if args.scratch: tasks.add('Destroy guests', self.destroy, args) if args.update: tasks.add('Update boxes', self.update, args) tasks.add('Bring up guests', self.up, args) tasks.add('Provision guests', self.provision, args) tasks.add_list([ Task('Make all images readable', self.make_readable, args, boxes), Task('Halt guests', self.halt, args), Task('Zero out empty space', self.zero_disks, args, boxes), Task('Create boxes', self.create_boxes, args, boxes), ]) if args.metadata: tasks.add('Create metadata', self.create_metadata, args, boxes) tasks.add('Finish', self.finish, args, boxes) tasks.run()
def __srv_start(self, task): if not self.server.running: self.log.info('Starting Server') self.tasks.put(Task(Task.NET_LINEUP, '[HANDLE] Starting Server...')) self.server.startserver() self.tasks.put(Task(Task.SCH_ADD, (Task(Task.API_CONNECT), 1) )) else: self.tasks.put(Task(Task.NET_LINEUP, '[HANDLE] The server is already running'))
def __srv_restart(self, task): if self.server.running: self.log.info('Restarting Server') self.api.cmd_q.put(ApiCmd(ApiCmd.DISCONNECT)) self.server.stopserver() self.tasks.put(Task(Task.SCH_ADD, (Task(Task.SRV_START), 10) )) self.tasks.put(Task(Task.NET_LINEUP, '[HANDLE] Server Stopped - Waiting 10 secs.....')) else: self.tasks.put(Task(Task.NET_LINEUP, "[HANDLE] The server isn't running"))
def __srv_stop(self, task): if self.server.running: self.log.info('Stopping Server') self.api.cmd_q.put(ApiCmd(ApiCmd.DISCONNECT)) self.server.stopserver() else: self.tasks.put(Task(Task.NET_LINEUP, '[HANDLE] The server is already stopped'))
def solve(self, task: Task21) -> Any: lines = task.lines if task.question_type == '–': lines = self.dash_not_in_line(lines) filters = [ (self.dash_has_number_range, 1), (self.dash_has_nsubj_over, 1), (self.dash_has_talk, 1), (self.dash_is_insert, 2), (self.dash_and, 1), ] for f, check_chars in filters: lines, group = self.filter_group('–', lines, f, check_chars) if group: return self.to_answer(task, group) if len(lines) > 1: filtered_data = task.data.copy() filtered_data['text'] = task.question_text + ' ' + ' '.join( [f'({i}) {line}' for i, line in enumerate(lines, 1)]) filtered_data['question']['choices'] = [{ "id": str(i), "link": f"({i})" } for i, line in enumerate(lines, 1)] sberbank_answer = self.sberbank_solver.solve(Task(filtered_data)) sberbank_lines = [lines[int(i) - 1] for i in sberbank_answer] return self.to_answer(task, sberbank_lines) else: return self.sberbank_solver.solve(task)
def task_test_case(self, task, args, command_directory, case): guests = case['machines'] default_guest = 'client' if 'client' in guests else guests[0] timeout = case.get('timeout', None) tasks = self.tasklist('Test Case: {}'.format(case['name']), [ Task('Destroying guests: {}'.format(guests), self.task_destroy, args.config, guests), Task('Starting up guests: {}'.format(guests), self.task_up, args.config, guests, command_directory, args.sssd, args.artifacts) ]) for step in case.get('tasks', []): tasks.add(step.get('name', ''), self.task_test_case_step, args.config, command_directory, step, default_guest)
def __clt_input(self, task): if task.data == 'close': self.tasks.put(Task(Task.CLT_CLOSE)) else: pack = Packet(Packet.INPUT,task.data) self.network.cmd_q.put(NetworkCommand(NetworkCommand.SEND,pack)) self.log.debug(':[H]Sent Command: ' + task.data)
def get(self): task = Task(self) ip = yield gen.Task(task.get_check) if ip: self.write(ip) self.finish() else: self.send_error(404)
def get(self, ip): """ 查看任务状态 """ task = Task(self) yield task.get_task_detail(ip) self.write('OK') self.finish()
def __on_connect(self, task): self.log.debug('ON_CONNECT RECEIVED') self.log.info('Client Connected') pack = Packet(Packet.UPDATE, [('handlev',self.database.config['Handle']['version'])]) self.network.cmd_q.put(NetworkCommand(NetworkCommand.SEND, pack)) if self.database.data['screen'] == None: self.database.data['screen'] = [] if len(self.database.data['screen']) == 100: self.database.data['screen'].pop(0) s = '[HANDLE] Connected to Handle ver. %s' % self.database.config['Handle']['version'] encodeds = s.encode('hex_codec') if not self.database.data['screen'][len(self.database.data['screen'])-1] == encodeds: self.database.data['screen'].append(encodeds) pack = Packet(Packet.UPDATE,[('screen',self.database.data['screen'])]) self.network.cmd_q.put(NetworkCommand(NetworkCommand.SEND,pack)) pack = Packet(Packet.UPDATE,[('events',self.schedule.visible_events)]) self.network.cmd_q.put(NetworkCommand(NetworkCommand.SEND,pack)) self.tasks.put(Task(Task.SCH_ADD,(Task(Task.SCH_UPDATE), 30, True))) self.api.cmd_q.put(ApiCmd(ApiCmd.RECONNECT))
def put(self, ip): """ 判断检测结果,需要处理的IP 则放入task队列 """ info = self.get_argument('info', '') status = self.get_argument('status', '') if status not in ['checked']: self.write("status Failed") self.finish() else: if info.find('True') > -1: task = Task(self) yield task.add_task(ip) self.write("OK") self.finish()
def generate_dtv_from_configfile(config, tasks, code=False): # default dictionary task_type_default = {} # for each type in configuration file for type_code, type_values in tasks.iteritems(): task_type = str(type_values['task_type']) slot_duration = None importance = None best_moment = None other_names = None max_qty = None if "slot_duration" in type_values.keys(): slot_duration = type_values['slot_duration'] if "importance" in type_values.keys(): importance = type_values['importance'] if "best_moment" in type_values.keys(): best_moment = type_values['best_moment'] if "other_names" in type_values.keys(): other_names = type_values['other_names'] if "max_qty" in type_values.keys(): max_qty = type_values['max_qty'] obj_task = Task(str(task_type), str(task_type), config, slot_duration=slot_duration, importance=importance, other_names=other_names, max_qty=max_qty, best_moment=best_moment) task_type_default[str(task_type)] = obj_task # return default tasks return task_type_default
def post(self): info = self.get_argument('info', '') task = Task(self) yield task.receive_report({'info': info}) self.write('OK') self.finish()
def get(self): task = Task(self) data_dict = yield gen.Task(task.get_report) self.render('report.html', data_dict=data_dict)
def get(self): task = Task(self) data_dict = yield gen.Task(task.get_blocklist) self.write(data_dict) self.finish()
def run(self, args, argv): self.tasklist('Provisioning Host', [ Task('Install Ansible', self.install_dependencies), Task('Run Ansible Playbook', self.run_ansible, args, argv) ]).run()
def run(self, args, argv): self.tasklist('Enroll', [ Task('Start Guest Machines', self.up, args), Task('Enroll Machines', self.enroll, args, argv) ]).run()
def interpret(self, command): if command == 'start': self.tasks.put(Task(Task.SRV_START)) elif command == 'stop': self.tasks.put(Task(Task.SRV_STOP)) elif command[:7] == 'restart': if len(command) == 7: self.tasks.put(Task(Task.SRV_RESTART)) else: self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] Resarting server in %s secs' %command[8:] )) delay = int(command[8:]) self.tasks.put(Task(Task.SCH_ADD,(Task(Task.SRV_RESTART), delay) )) elif command == 'exit': self.tasks.put(Task(Task.HDL_EXIT)) elif command == 'help' or command == '?': self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE]=======================Handle Commands===============================')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] Optional arguements in brackets []')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE]')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] start start the server')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] stop stop the server')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] restart [delay] restart the server')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] exit stop the server and close Handle')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] close close the client but leave Handle running')) self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] Use the Left/Right Keys to change sidebar tabs')) self.tasks.put(Task(Task.SRV_INPUT, 'help')) elif command == 'serve_welcome_packet': self.tasks.put(Task(Task.NET_LINEUP,'Connected to Handle ver. %s' %self.database.config['Handle']['version'])) elif command[:10] == 'test_event': self.tasks.put(Task(Task.SCH_ADD, (Task(Task.NET_LINEUP, '%s' % command[11:]), 5))) self.tasks.put(Task(Task.NET_LINEUP, 'added test task')) elif command[:11] == 'test_method': ao = ApiObj(command[12:], 30) self.tasks.put(Task(Task.API_REGISTER, ao)) self.tasks.put(Task(Task.API_UPDATE, ao)) self.tasks.put(Task(Task.NET_LINEUP, 'added test method')) elif command == 'backup': self.tasks.put(Task(Task.SRV_BACKUP)) else: if self.server.running: self.tasks.put(Task(Task.SRV_INPUT, command)) else: self.tasks.put(Task(Task.NET_LINEUP,'[HANDLE] Unknown Command, For help, type "help" or "?"'))
def get(self): task = Task(self) data_dict = yield gen.Task(task.get_umail_ips) self.render('umail.html', data_dict=data_dict)
parser.add_argument( 'use_trace', type=int, default=0, help="0 to build from scratch, 1 to use processes' trace") parser.add_argument( '--tpl_path', type=str, default='data/tpl_static_info.json', help="Register the path to the tpl static info json file") parser.add_argument('--trace_path', type=str, default='data/trace.json', help="Register the path to the trace json file") args = parser.parse_args() sched = TaskMaster() if args.use_trace == True: sched.generateGanttFromJson(args.tpl_path, args.trace_path) else: t1 = Task('Task 1', [(0, 50)]) t2 = Task('Task 2', [(50, 20)]) t3 = Task('Task 3', [(70, 10), (150, 30)]) idle = Task('Idle', [(180, 100)]) t4 = Task('Task 4', [(80, 70)]) sched.registerTask(t1) sched.registerTask(t2) sched.registerTask(t3) sched.registerTask(t4) sched.registerTask(idle) sched.plotGantt()