Exemplo n.º 1
0
def scroll_button_display(object, class_type):
    text = 'scroll_button_display NOT SET UP FOR CLASS TYPE'
    bg="gray99"
    if class_type == 'task':
        from datetime import date
        from lib.task import Task
        till_due = Task.date_length(str(date.today()), object.due)
        till_deadline = ''
        text_deadline = ''
        if object.deadline != '':
            till_deadline = Task.date_length(str(date.today()), object.deadline)
            text_deadline = '[' + object.deadline + ' (' + str(till_deadline) + ')] '
        text = '[' + object.staff + '] '
        text += object.due + ' (' + str(till_due) + ')'
        text += ' - ' + object.property + ' - ' + text_deadline + object.message
        text += ' {' + object.next + '}'
        if till_due > 30: bg = 'grey'
        if till_due < 1: bg = 'orange'
        if till_due < 0: bg = 'tomato'
        if till_due < -5: bg = 'firebrick'
    if class_type == 'action':
        text = object.date + ' - ' + object.property + ' - ' + object.message
    if class_type == 'property':
        text = object.code + ' - ' + object.address
    if class_type == 'landlord':
        text =  object.code + ' - ' + object.surname + ', ' + object.first_names + ' (' + object.title + ') - ' + object.note
    if class_type == 'contact':
        text =  object.type + ' - ' + object.address + ' (' + object.note + ')'
    return text, bg
Exemplo n.º 2
0
    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()
Exemplo n.º 3
0
 def get(self, ip):
     """
     查看任务状态
     """
     task = Task(self)
     yield task.get_task_detail(ip)
     self.write('OK')
     self.finish()
Exemplo n.º 4
0
	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'))
Exemplo n.º 5
0
	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"))
Exemplo n.º 6
0
 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()
Exemplo n.º 7
0
	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)
Exemplo n.º 8
0
	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'))
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
    def see_window_right(window, user, number):
        row = 0
        column = 5
        Widget.line(window, user, '', row, column)
        column += 1

        break_line = ''
        for i in range(102): break_line += '-'

        text = '[' + user.task_list[number].staff + ']'
        text += ' (Startdate: ' + user.task_list[number].date + ')'
        text += ' Deadline: ' + user.task_list[number].deadline
        Widget.line(window, user, text, row, column)
        row += 1

        line = Property.address_from_code(user, user.task_list[number].property)
        Widget.title(window, user, line, row, column)
        row += 1

        text = 'Description: ' + user.task_list[number].message
        Widget.content(window, user, text, row, column)
        row += 1

        Widget.line(window, user, break_line, row, column)
        row += 1

        till_deadline = ''
        alert = False
        if user.task_list[number].deadline != '':
            till_deadline = Task.date_length(str(date.today()), user.task_list[number].deadline)
            if till_deadline < 1: alert = True
        line = 'Days till deadline: ' + str(till_deadline)
        Widget.line(window, user, line, row, column, alert)
        row += 1

        till_due = Task.date_length(str(date.today()), user.task_list[number].due)
        alert = False
        if till_due < 1: alert = True
        line = 'Days till due: ' + str(till_due)
        Widget.title(window, user, line, row, column, alert)
        row += 1

        text = 'Next Action: ' + user.task_list[number].next
        Widget.content(window, user, text, row, column)
        row += 1
Exemplo n.º 13
0
def task_to_json(config, task, tasks):

    event = {}
    event['summary'] = task[0]
    event['start'] = {}
    event['start']['dateTime'] = task[1].strftime(
        "%Y-%m-%dT%H:%M:%S") + config.google_calendar_config['gmt_off']
    event['end'] = {}
    event['end']['dateTime'] = task[2].strftime(
        "%Y-%m-%dT%H:%M:%S") + config.google_calendar_config['gmt_off']

    if config.reminders[0]:
        event['reminders'] = {}
        event['reminders']['useDefault'] = False
        event['reminders']['overrides'] = []
        event['reminders']['overrides'].append({
            'method': 'popup',
            'minutes': config.reminders[1]
        })

    actvity = Task.get_activity_from_array(task[0], tasks)
    if actvity != None and actvity.description != None:
        event['description'] = actvity.description
    elif len(task) > 3 and task[3] != None:
        event['description'] = task[3]

    # event = {
    #   'summary': 'Google I/O 2015',
    #   'location': '800 Howard St., San Francisco, CA 94103',
    #   'description': 'A chance to hear more about Google\'s developer products.',
    #   'start': {
    #     'dateTime': '2015-05-28T09:00:00-07:00',
    #     'timeZone': 'America/Los_Angeles',
    #   },
    #   'end': {
    #     'dateTime': '2015-05-28T17:00:00-07:00',
    #     'timeZone': 'America/Los_Angeles',
    #   },
    #   'recurrence': [
    #     'RRULE:FREQ=DAILY;COUNT=2'
    #   ],
    #   'attendees': [
    #     {'email': '*****@*****.**'},
    #     {'email': '*****@*****.**'},
    #   ],
    #   'reminders': {
    #     'useDefault': False,
    #     'overrides': [
    #       {'method': 'email', 'minutes': 24 * 60},
    #       {'method': 'popup', 'minutes': 10},
    #     ],
    #   },
    # }

    return event
Exemplo n.º 14
0
 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()
Exemplo n.º 15
0
	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))
Exemplo n.º 16
0
    def __init__(self, config_file, tasks_file):

        infos = json.loads(open(config_file).read())
        tasks = json.loads(open(tasks_file).read())

        print "There is a mistake in printing"

        self.tasker_config = infos['tasker_config']
        self.google_calendar_config = infos['google_calendar_config']
        self.default_time_start_working_day = infos[
            'default_time_start_working_day']
        self.default_time_start_lunch = infos['default_time_start_lunch']
        self.default_time_end_lunch = infos['default_time_end_lunch']
        self.default_time_end_working_day = infos[
            'default_time_end_working_day']
        self.default_time_start_dinner = infos['default_time_start_dinner']
        self.default_time_end_dinner = infos['default_time_end_dinner']
        self.default_time_end_day = infos['default_time_end_day']
        self.default_early = infos['default_early']
        self.default_central = infos['default_central']
        self.default_late = infos['default_late']
        self.task_type_code = infos['task_type_code']
        self.daymoment_activity_probability = infos[
            'daymoment_activity_probability']
        self.default_activity_mode = infos['default_activity_mode']
        self.task_type_default = infos['task_type_default']
        self.task_reminders = infos['task_reminders']

        self.task_list = tasks['task_list']

        if self.default_activity_mode < 2:
            self.task_type_default = Config.generate_dtv_from_configfile(
                self, self.task_type_default)
        elif self.default_activity_mode == 2:
            self.task_type_default = Task.generate_dtv_from_tasklist(
                self, self.task_list)

        self.task_list = Task.generate_otl_from_taskfile(self, self.task_list)
Exemplo n.º 17
0
    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
Exemplo n.º 18
0
 def get(self):
     task = Task(self)
     data_dict = yield gen.Task(task.get_umail_ips)
     self.render('umail.html', data_dict=data_dict)
Exemplo n.º 19
0
 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()
Exemplo n.º 20
0
    # start and end time calculation
    end_day = set_to_midnight(today + datetime.timedelta(days=1))
    start_day = set_to_midnight(today)

    # Day scheduling
    print "Day scheduling  %s." % start_day.strftime("%d %B %Y")

    # day time calculation
    time_start_working_day, \
    time_start_lunch, \
    time_end_lunch, \
    time_end_working_day, \
    time_start_dinner, \
    time_end_dinner, \
    time_end_day = Task.get_day_time(config, default_date = (not intercative_hour_choices), start_day = start_day)

    # temporal_slots calculation
    temporal_slots = Task.get_temporal_slots(config, \
                                             time_start_working_day, \
                                             time_start_lunch, \
                                             time_end_lunch, \
                                             time_end_working_day, \
                                             time_start_dinner, \
                                             time_end_dinner, \
                                             time_end_day)

    # get list of relevant events
    relevant_events = events = get_relevant_events(config, service,
                                                   calendars_name, start_day,
                                                   end_day)
Exemplo n.º 21
0
	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 "?"'))
Exemplo n.º 22
0
 def post(self):
     info = self.get_argument('info', '')
     task = Task(self)
     yield task.receive_report({'info': info})
     self.write('OK')
     self.finish()
Exemplo n.º 23
0
 def get(self):
     task = Task(self)
     data_dict = yield gen.Task(task.get_report)
     self.render('report.html', data_dict=data_dict)
Exemplo n.º 24
0
 def get(self):
     task = Task(self)
     data_dict = yield gen.Task(task.get_blocklist)
     self.write(data_dict)
     self.finish()
Exemplo n.º 25
0
 def run(self, args, argv):
     self.tasklist('Enroll', [
         Task('Start Guest Machines', self.up, args),
         Task('Enroll Machines', self.enroll, args, argv)
     ]).run()
Exemplo n.º 26
0
 def dropTask(self,e):
     Task.dropTask(self, e)
Exemplo n.º 27
0
    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()