示例#1
0
    def task_update(self, task):
        description = ""

        matter = utils.parse_matter(sys.stdin.read())
        post = matter['frontmatter']
        description = matter['content'].strip()

        t = model.Task(None)
        t.phid = utils.phid_lookup(task)

        if not t.phid:
            print("Error looking up Task number...")
            return -1

        t.description = description

        if ('title' in post):
            t.title = post['title']
        if ('points' in post):
            t.points = post['points']
        if ('assigned' in post):
            t.assigned = post['assigned']

        if len(matter['comment']):
            t.comment = matter['comment']

        t.commit()
示例#2
0
    def ParseItem(self, item):
        """Parses a single CSV row and stores the resulting entity.

    Args:
      item: a csv row object representing an Outlook todo item.

    Returns:
      The entity created by parsing item.
    """
        task = model.Task()
        if self.tasklist:
            task.parent_entity = self.tasklist
        if item["Subject"]:
            task.title = item["Subject"]
        else:
            # we need a title so if it's not there we use the empty string
            task.title = ""
        if item["Notes"]:
            task.notes = item["Notes"]
        if item["Due Date"]:
            task.due = datetime.datetime.strptime(item["Due Date"],
                                                  "%m/%d/%Y").date()
        if item["Date Completed"]:
            task.completed = datetime.datetime.strptime(
                item["Date Completed"], "%m/%d/%Y")
        if item["Status"]:
            if item["Status"] == "Complete":
                task.status = "completed"
            else:
                task.status = "needsAction"
        task.put()
        return task
示例#3
0
 def test_get_task_depth(self):
     '''testing the task_depth method'''
     child = model.Task(
         start_time="Jun 28, 2017 15:18:38",
         parent=self.task_id)
     child_id = child.cget('task_id')
     self.database.addtask(child)
     self.database.hidden_config(self.task_id, children=[child_id])
     self.assertEqual(self.database.get_task_depth(child_id), 1)
示例#4
0
 def test_get_all_children(self):
     '''testing the get_all_children method'''
     child1 = model.Task(
         parent=self.task_id,
         start_time="Jun 28, 2017 15:18:38")
     child1_id = child1.cget('task_id')
     child2 = model.Task(
         parent=child1_id,
         start_time="Jun 28, 2017 15:18:38")
     child2_id = child2.cget('task_id')
     child1.hidden_config(children=[child2_id])
     self.database.hidden_config(self.task_id, children=[child1_id])
     self.database.addtask(child1)
     self.database.addtask(child2)
     self.assertEqual(
         self.database.get_all_children(
             self.task_id), [
                 child1_id, child2_id])
示例#5
0
def submit():
    email = request.args.get('email')
    print(email)
    url = request.args.get('url')
    print(url)

    id = uuid.uuid4()

    model.Task(str(id), url, email).run()

    return jsonify({'id': str(id)}), 200
示例#6
0
文件: LYPA_cl.py 项目: lightvfx/LYPA
 def addTask(self, name, shortName, job, In, Out, cmd, Type):
     print "adding task to " + job
     curJob = model.Job.get_by(Name=unicode(job))
     newTask = model.Task(Name=name,
                          In=In,
                          Out=Out,
                          Type=Type,
                          ShortName=shortName,
                          Status=101,
                          Command=cmd)
     curJob.Tasks.append(newTask)
     model.saveData()
示例#7
0
	def begin_recommendations(self, data):
		offset = data['offset']
		articles = model.Article.all().filter('draft', False).filter('deletion_date', None).order('creation_date').fetch(1, offset)
		print 'articles: %d' % len(articles)
		if len(articles) == 0:
			return None

		next = articles[0]
		data['offset'] += 1

		t = model.Task(task_type='article_recommendation', priority=0, data=simplejson.dumps({'article': next.key().id(), 'offset': 0}))
		t.put()

		return data
示例#8
0
 def setUp(self):
     '''setting up fixations'''
     os.chdir("/home/pcastr/toolsets/toolset/contrib/nightvision/unittests")
     self.database = model.Model()
     self.task = model.Task(start_time="Jun 28, 2017 15:18:38")
     self.task_id = self.task.information['task_id']
     self.database.addtask(self.task)
     if not os.path.exists("local_database"):
         os.makedirs("local_database")
     if not os.path.exists("dummy_dir"):
         os.makedirs("dummy_dir")
     if not os.path.exists("resources"):
         os.makedirs("resources")
     with open(LOG_SOURCES_FILE, 'w') as txtfile:
         txtfile.write("/projects/alegra/testing/logs/trigger.log")
示例#9
0
    def ParseItem(self, item):
        """Parses a single VTODO object and stores the resulting entity.

    Args:
      item: an icalendar object representing a VTODO object.

    Returns:
      The entity created by parsing item.
    """

        logging.info(item)

        task = model.Task()
        if self.tasklist:
            task.parent_entity = self.tasklist
        if "summary" in item.contents:
            task.title = item.summary.value
        else:
            # we need a title so if it's not there we use the empty string
            task.title = ""
        if "description" in item.contents:
            task.notes = item.description.value
        if "due" in item.contents:
            due = item.due.value
            if isinstance(due, datetime.datetime):
                task.due = due.date()
            elif isinstance(due, datetime.date):
                task.due = due
        if "completed" in item.contents:
            # we don't use the status field because iCalendar doesn't always specify
            # it on completed tasks
            task.status = "completed"
            task.completed = item.completed.value
        else:
            task.status = "needsAction"
        task.put()
        return task
示例#10
0
 def setUp(self):
     '''setting up fixations'''
     self.database = model.Model()
     self.task = model.Task(start_time="Jun 28, 2017 15:18:38")
     self.task_id = self.task.information['task_id']
示例#11
0
文件: LYPA_cl.py 项目: lightvfx/LYPA
    def addRender(self, project, shot, first, last, ver, path, RenderScenefile,
                  type, w, h, renderOutput, renderName, jobName, jobType,
                  format, curUserName, Schunk, cmd):
        print "go2"
        #jobName = "job_" + renderName + time.strftime('_%d%m%y_%H%M%S')
        chunk = int(Schunk)
        curShot = model.Shot.get_by(Name=unicode(shot))
        curProj = model.Project.get_by(Name=unicode(project))
        now = datetime.datetime.now()
        newRender = model.Render(Name=renderName,
                                 In=int(first),
                                 Out=int(last),
                                 Path=path,
                                 Date=now,
                                 version=int(ver),
                                 ScenePath=RenderScenefile,
                                 Type=type,
                                 Width=int(w),
                                 Height=int(h),
                                 Format=format,
                                 Job=jobName,
                                 User=curUserName)
        model.saveData()
        curShot.Renders.append(newRender)
        curShot.Seq.Renders.append(newRender)
        curProj.Renders.append(newRender)
        model.saveData()
        newJob = model.Job(Name=jobName, Type=jobType, Status=101)
        model.saveData()

        startFrame = int(first)
        curChunk = 0
        taskDir = renderOutput + "/tasks"

        for i in range(int(first), int(last), chunk):
            if curChunk == (int(last) - int(first)) / chunk - 1:
                shortName = "task" + "_" + "%04d" % i
                taskName = jobName + "_" + "%04d" % i
                taskFile = taskDir + "/" + taskName + ".txt"
                newTask = model.Task(Name=taskName,
                                     In=startFrame,
                                     Out=last,
                                     Type=jobType,
                                     ShortName=shortName,
                                     Status=101,
                                     Command=unicode(RenderScenefile +
                                                     " -taskFile " + taskFile))
                newJob.Tasks.append(newTask)
            else:
                shortName = "task" + "_" + "%04d" % i
                taskName = jobName + "_" + "%04d" % i
                taskFile = taskDir + "/" + taskName + ".txt"
                newTask = model.Task(Name=taskName,
                                     In=startFrame,
                                     Out=startFrame + chunk - 1,
                                     Type=jobType,
                                     ShortName=shortName,
                                     Status=101,
                                     Command=unicode(RenderScenefile +
                                                     " -taskFile " + taskFile))
                newJob.Tasks.append(newTask)
            startFrame += chunk
            curChunk += 1
            model.saveData()
示例#12
0
 def create_task(self, task_type, priority, data):
     import simplejson
     t = model.Task(task_type=task_type,
                    priority=priority,
                    data=simplejson.dumps(data))
     t.put()
示例#13
0
    def on_post(self, req, resp):
        """
        Vytvoreni nove ulohy

        Specifikace POST pozadavku:
        {
            "task": {
                "wave": Integer, <- id vlny
                "title": String,
                "author": Integer, <- id autora
                "git_path": String, <- adresar ulohy v GITu vcetne cele cesty
                "git_branch": String, <- nazev gitove vetve, ve ktere vytvorit
                    ulohu / ze ktere cerpat data pro deploy
                "git_commit" String <- hash posledniho commitu, pokud je
                    ?create_git=true, nevyplnuje se
                "git_create" Bool <- jestli ma dojit k vytvoreni gitovskeho
                    adresare a vetve ulohy
            }
        }

        """

        try:
            user = req.context['user']
            year = req.context['year']
            data = json.loads(req.stream.read().decode('utf-8'))['atask']
            wave = session.query(model.Wave).get(data['wave'])

            if wave is None:
                resp.status = falcon.HTTP_404
                return

            # Vytvorit novou ulohu mohou jen admini nebo garanti vlny.
            if (not user.is_logged_in()) or (not user.is_admin() and
                                             user.id != wave.garant):
                resp.status = falcon.HTTP_400
                return

            # Ulohu lze vytvorit jen pred casem zverejneni vlny
            if datetime.datetime.utcnow() > wave.time_published:
                resp.status = falcon.HTTP_403
                return

            # Vytvoreni adresare v repu je option:
            if ('git_create' in data) and (data['git_create']):
                # Kontrola zamku
                lock = util.lock.git_locked()
                if lock:
                    resp.status = falcon.HTTP_409
                    return

                newLock = LockFile(util.admin.task.LOCKFILE)
                newLock.acquire(60)  # Timeout zamku je 1 minuta

                try:
                    git_commit = util.admin.task.createGit(
                        data['git_path'], data['git_branch'],
                        int(data['author']), data['title'])
                finally:
                    newLock.release()
            else:
                git_commit = data['git_commit']\
                    if 'git_commit' in data else None

            # Nejprve vytvorime nove diskuzni vlakno
            taskThread = model.Thread(
                title=data['title'],
                public=True,
                year=req.context['year']
            )
            session.add(taskThread)
            session.commit()

            # Pote vytvorime ulohu
            task = model.Task(
                wave=data['wave'],
                title=data['title'],
                author=data['author'],
                git_path=data['git_path'],
                git_branch=data['git_branch'],
                git_commit=git_commit,
                thread=taskThread.id
            )

            session.add(task)
            session.commit()

            req.context['result'] = {'atask': util.task.admin_to_json(task)}
        except SQLAlchemyError:
            session.rollback()
            raise
        finally:
            session.close()
示例#14
0
 def test_create_task(self):
     """Create new task."""
     task = model.Task()
     self.assertIsInstance(task, model.Task)
示例#15
0
def set_file_data(parse_pattern):
    record_nums = 0
    file_data = {}
    if parse_pattern == GdbPattern:
        file_data = data_IO.read_from_txt()
        attr = data_IO.Log2ClassAttrMap.get(data_IO.LogAttrList[0])
        record_nums = len(file_data[attr])

    # 更新task_dict
    LoadingData = []
    LoadTaskDict = {}
    for idx in range(record_nums):
        task_data = get_attr_dict(file_data, idx)
        task_id = task_data.get('task_id')
        now_esp = task_data.get('esp')
        now_ebp = task_data.get('ebp')
        now_task_ebp = task_data.get('task_ebp')
        now_task_esp = task_data.get('task_esp')

        # 获取对应的taskObj
        task_obj = LoadTaskDict.get(task_id) or model.Task(task_id=task_id)
        last_stack_info = task_obj.stack_infos[
            -1] if task_obj.stack_infos else None

        remake = True
        last_method_list = None
        stack_info = model.StackInfo()
        method_names = task_data.get('method_names')
        if last_stack_info:
            last_method_list = [
                method_info for method_info in last_stack_info.method_infos
            ]

            method_len = len(method_names)
            stack_len = len(last_method_list)

            if stack_len - 1 == method_len and last_method_list[
                    -2].method == method_names[-1]:
                last_method_list = last_method_list[:-1]
                remake = False
            elif stack_len + 1 == method_len and last_method_list[
                    -1].method == method_names[-2]:
                last_method_list.append(
                    model.MethodInfo(now_task_esp, now_task_ebp, now_esp,
                                     now_ebp, method_names[-1]))
                remake = False

        if not remake:
            stack_info.add_method_infos(last_method_list)
        else:
            if len(method_names) > 1:
                make_ebp = "0x0"
                if len(method_names) > 2:
                    for method_idx in range(len(method_names) - 2):
                        stack_info.add_method_info(now_task_esp, now_task_ebp,
                                                   "unkown", make_ebp,
                                                   method_names[method_idx])
                        make_ebp = "unkown"

                stack_info.add_method_info(now_task_esp, now_task_ebp,
                                           str(hex(int(now_ebp, 16) - 8)),
                                           make_ebp, method_names[-2])
            stack_info.add_method_info(now_task_esp, now_task_ebp, now_esp,
                                       now_ebp, method_names[-1])

        # 添加当前栈的信息
        task_obj.add_stack_info(stack_info)

        # 加入新加的数据
        LoadingData.append(
            model.ShowInfo(
                task_id=task_obj.task_id,
                stack_idx=task_obj.info_len - 1,
            ))
        LoadTaskDict[task_id] = task_obj

    return LoadingData, LoadTaskDict