Exemplo n.º 1
0
def saveActiveProjectTaskMapping(worksheet: Worksheet,
                                 startRow: int = 1,
                                 startColumn: int = 1):
    """Saves the active project list and active task list data.
    The projects are stored in one row, the tasks corresponding to the project are saved in the same column as the project
    
    Arguments:
        worksheet {Worksheet} -- [description]
        startRow {int} -- starting row form where the data should be stored
        startColumn {int} -- starting column form where the data should be stored
    """
    projectList = excelDatabase.getActiveProjects()
    if projectList is None:
        return
    for project in projectList:
        taskList = excelDatabase.getActiveTasksByProjectId(project.projectId)
        if taskList is None:
            taskList = []
            task = Task()
            task.taskName = "-"
            taskList.append(task)
        project.taskList = taskList
    defaultProject = getDefaultProjects()
    projectList.extend(defaultProject)
    column = startColumn
    for project in projectList:
        row = startRow
        worksheet.cell(row=row, column=column).value = project.projectName
        for task in project.taskList:
            row += 1
            worksheet.cell(row=row, column=column).value = task.taskName
        column += 1
Exemplo n.º 2
0
    def run(self):
        tz = pytz.timezone('Europe/Budapest')
        self.task = Task(self.task_id)
        end_date = dateutil.parser.parse(self.task.end_date)
        first_channel = int(self.task.first_channel)
        second_channel = int(self.task.second_channel)
        third_channel = int(self.task.third_channel)
        with Edaq530([first_channel, second_channel, third_channel]) as edaq530:
            #mérést megvalósító kód
            converter = Edaq530Converters()
            while self.running:
                time.sleep(self.task.delay)
                #measurements = edaq530.getMesurementInCelsius()
                measurements = edaq530.getMesurements()
                calculatedMeasurements = []

                for i in range(0,3):
                    # ADC to Voltage
                    x = converter.adcCodeToVoltage(measurements[i])
                    calculatedMeasurements.append(eval(self.task.first_equation))

                self.task.insertMeasurements(calculatedMeasurements)
                self.redis.publish('edaq530', json.dumps({'event': 'new_value', 'data': calculatedMeasurements}))
                now = datetime.datetime.now()
                if(now > end_date):
                    self.stop()
 def start_task(self):
     Task.start_task(self)
     # store messages in message_votes
     for m in self.messages:
         # this adds the message to the db
         m = self.MessageType(str(self.experiment.exp_id),
                              m['text'].encode('utf-8'), str(m['_id']),
                              m['shortname'], self.task_id,
                              {'task_type': self.task_type})
Exemplo n.º 4
0
 def new_task(self,author, title, description,date):
   new_task = Task(__key__=self.cid,
                   author=author,
                   title=title,
                   description=description,
                   done=False,
                   date=date)
   new_task.put()
   values = {'task': new_task}
   return values
Exemplo n.º 5
0
    def test_saves_and_gets_task(self):
        sut = InMemoryStorage()
        task1 = Task("id1", "")
        task2 = Task("id2", "")
        task3 = Task("id3", "")

        sut.save(task1)
        sut.save(task2)
        sut.save(task3)

        self.assertEqual(sut.get_task("id2"), task2)
Exemplo n.º 6
0
    def test_deletes_task(self):
        sut = InMemoryStorage()
        task1 = Task("id1", "")
        task2 = Task("id2", "")
        task3 = Task("id3", "")
        sut.save(task1)
        sut.save(task2)
        sut.save(task3)

        sut.delete_task_by_id("id2")

        self.assertEqual(sut.get_task("id2"), None)
    def start_task(self):
        Task.start_task(self)

        # create docs in votesc collection
        def assign_task_id(m):
            m['task_id'] = str(self.task_id)
            m['task_type'] = str(self.task_type)
            db[self.votesc].insert(m)

        for m in self.messages:
            assign_task_id(m)
            
        for m in self.already_fixed_messages:
            assign_task_id(m)
Exemplo n.º 8
0
def dispatchTasks(tasksConfigs, build_id):
    # print(tasksConfigs)
    rawTasks = []
    for taskName in tasksConfigs['tasks']:
        task = tasksConfigs['tasks'][taskName]
        task['returnChannel'] = 'default'
        rawTasks.append(task)

    tasks = []

    for rawtask in rawTasks:
        task = Task(id=uuid.uuid4(),
                    next=None,
                    build_id=build_id,
                    state='pending',
                    config_file=json.dumps(rawtask))

        tasks.append(task)

    eofTask = Task(id=uuid.uuid4(),
                   next=None,
                   build_id=build_id,
                   state='pending',
                   config_file=json.dumps({
                       'type': 'eof',
                       'returnChannel': 'default'
                   }))
    tasks.append(eofTask)

    for i in range(len(tasks) - 1):
        print(i, tasks[i].id)
        tasks[i].next = str(tasks[i + 1].id)

    for task in tasks:
        db.session.add(task)
        print(task)

    db.session.commit()

    connection = pika.BlockingConnection(
        pika.ConnectionParameters(host='localhost'))
    channel = connection.channel()
    channel.queue_declare(queue='tasks')
    channel.basic_publish(exchange='',
                          routing_key='tasks',
                          body=json.dumps(tasks[0].toJSON()))

    connection.close()

    return tasks[0]
Exemplo n.º 9
0
def createTaskFromRequestArguments(arguments):
    appname, = arguments['appname']
    interval, = arguments['group_interval']
    task = Task(appname = appname, interval = interval)
    indexes = arguments['indexes']
    userUniques = []
    if arguments.has_key('userUnique'):
        userUniques = arguments['userUnique']

    for index in indexes:
        if not arguments.has_key('key_' + index):
            continue

        eventCode, = arguments['key_' + index]
        if not eventCode:
            continue

        start = datetime.strptime(repMonth(arguments['start_'+ index][0]), "%d %m %Y %H:%M")
        end = datetime.strptime(repMonth(arguments['end_'+ index][0]), "%d %m %Y %H:%M")

        taskItem = TaskItem(key = eventCode, start = start, end = end, index = index)
        if index in userUniques:
            taskItem.userUnique = True
        # разбираем тег для ключа
        tagNames = []
        tag_name = 'tag_' + index + '_name'
        if arguments.has_key(tag_name):
            tagNames = arguments[tag_name]

        for tagName in tagNames:
            # значения тега
            values = None
            val_index = 'tag_' + index + '_' + tagName
            if arguments.has_key(val_index):
                # convert to unicode
                values = [val.decode('utf-8') for val in arguments[val_index]]

            if not values is None:
                taskItem.addCondition(eventCode, tagName, values)
            # операции с тегом
            op_index = 'tag_' + index + '_' + tagName + '_ops'
            if arguments.has_key(op_index):
                ops = arguments[op_index][0]
                if not ops is None:
                    taskItem.setTagOperations(tagName, ops.split('/'))

        task.addTaskItem(taskItem)

    return  task
Exemplo n.º 10
0
 def getTasksForBranch(self, BranchID, ProjectID):
     return [
         Task(tuple) for tuple in
         self._db.execute("""
                 select * from Task where BranchID={bid} and ProjectID={pid};"""
                          .format(bid=BranchID, pid=ProjectID)).fetchall()
     ]
Exemplo n.º 11
0
def updatetask():
    taskname = request.form['taskname']
    formdata = request.form.to_dict()
    query = Task.remove_empty_from_dict(formdata)
    modifieddate = datetime.now().strftime("%Y-%m-%d")
    query.update({'modifieddate': modifieddate})
    print(query)

    Task.update_dbdoc(taskname, query)

    if session['isadmin'] == "Admin":
        return redirect(
            url_for('admin',
                    message="{} Update successfully".format(taskname)))
    else:
        return redirect(
            url_for('user', message="{} Update successfully".format(taskname)))
Exemplo n.º 12
0
def getDefaultProjects() -> list:
    """Creates default projects as defined in the configuration
    with default task "-".
    
    Returns:
        list -- List of Projects
    """
    projectList = []
    for projectName in DEFAULT_PROJECT:
        project = Project()
        project.projectName = projectName
        taskList = []
        task = Task()
        task.taskName = "-"
        taskList.append(task)
        project.taskList = taskList
        projectList.append(project)
    return projectList
Exemplo n.º 13
0
def getActiveTasksByProjectId(projectId: int) -> list:
    """Get active tasks by project ID
    
    Arguments:
        projectId {int} -- [description]
    """
    cursor = connection.cursor()
    cursor.execute(SQLQueries.ACTIVE_TASK_BY_PROJECTNAME_GET,
                   [projectId, "active"])
    queryResult = cursor.fetchall()
    if (len(queryResult) == 0):
        return None
    taskList = []
    for task in queryResult:
        taskData = Task()
        taskData.taskName = task[0]
        taskList.append(taskData)
    return taskList
Exemplo n.º 14
0
 def object_hook(self, dct):
     if 'task_id' in dct:
         return Task(dct['task_id'], dct['m'], dct['s'],
                     dct['out_line_cost'], set(dct['predecessor_set']))
     elif 'instance_id' in dct:
         return Instance(dct['instance_id'],
                         {task.task_id: task
                          for task in dct['task_list']}, dct['q'], dct['c'])
     else:
         super().object_hook(self, dct)
Exemplo n.º 15
0
def addtask():

    print(request.form)
    taskname = request.form['TaskName']
    owner = request.form['owner']
    summary = request.form['Summary']
    managedby = request.form['managedby']
    percent = request.form['percent']
    comments = request.form['comments']
    eta = request.form['eta']
    status = request.form['Status']
    task = Task(taskname, owner, summary, managedby, percent, comments, eta,
                status)
    task.save_to_db()
    message = "Task {} added to Database".format(taskname)

    if session['isadmin'] == "Admin":
        return redirect(url_for('admin', message=message))
    else:
        return redirect(url_for('user', message=message))
Exemplo n.º 16
0
 def post(self):
     try:
         body = request.get_json()
         task = Task(**body).save()
         id = task.id
         return {'id': str(id)}, 200
     except (FieldDoesNotExist, ValidationError):
         raise SchemaValidationError
     except NotUniqueError:
         raise TaskAlreadyExistsError
     except Exception as e:
         raise InternalServerError
Exemplo n.º 17
0
def measurementStatusSubscriber(pubsub, redis):
    #print(threading.enumerate())
    getMessage = pubsub.get_message()
    if getMessage != None and getMessage.get('type') == 'message':
        data = json.loads(getMessage.get('data').decode('UTF-8'))
        if data.get('event') == 'schedule_task':
            taskData = data.get('data')
            task = Task.createTask(taskData.get('name'),
                                   taskData.get('first_channel'),
                                   taskData.get('first_equation'),
                                   taskData.get('second_channel'),
                                   taskData.get('second_equation'),
                                   taskData.get('third_channel'),
                                   taskData.get('third_equation'),
                                   taskData.get('delay'),
                                   taskData.get('end_date'))
            startScheduledMeasurment(task.id, redis, pubsub)
        if data.get('event') == 'ask_active_threads':
            redis.publish(
                'edaq530',
                json.dumps({
                    'event': 'active_threads',
                    'data': threading.active_count()
                }))
Exemplo n.º 18
0
 def getTask(self, TaskID):
     return [
         Task(tuple) for tuple in self._db.execute("""
     select * from Task where TaskID={id};""".format(id=TaskID)).fetchall()
     ][0]
Exemplo n.º 19
0
 def get(self):
     tasks = Task.objects().to_json()
     return Response(tasks, mimetype="application/json", status=200)
Exemplo n.º 20
0
 def get_tasks(self):
     return [Task("id", "summary")]
Exemplo n.º 21
0
 def getTasksForProject(self, ProjectID):
     return [
         Task(tuple) for tuple in self._db.execute("""
                 select * from Task where ProjectID={pid};""".format(
             pid=ProjectID)).fetchall()
     ]
Exemplo n.º 22
0
 def getTasksForStudent(self, StudentID):
     return [
         Task(tuple) for tuple in self._db.execute(
             """select * from Task where StudentID={id};""".format(
                 id=StudentID)).fetchall()
     ]
Exemplo n.º 23
0
 def add_task(self, task_summary) -> str:
     new_task = Task("some id", task_summary)
     return self._task_gateway.save(new_task)