• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python model.Task类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中model.Task的典型用法代码示例。如果您正苦于以下问题:Python Task类的具体用法?Python Task怎么用?Python Task使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Task类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_task_process_rule

def test_task_process_rule(capsys):
    task = Task('./tests/music', '.*\.mp3')
    rule = Rule(Artist='Metallica')
    task.add_rule(rule)
    task.process_rules()
    out, err = capsys.readouterr()
    assert out == 'Update some.mp3. Set Artist to Metallica\n'
开发者ID:tsyganov-ivan,项目名称:PiterPy3,代码行数:7,代码来源:test_model.py


示例2: execute

 def execute(self):
     t = Task(self.name)
     if self.should_be_active:
         t.activate()
     session.add(t)
     session.commit()
     print "Added task %d." % t.id
开发者ID:soulplant,项目名称:tasks,代码行数:7,代码来源:main.py


示例3: make_task

def make_task(script):
    parsed_script = script_parser.parseString(open(script).read())
    data = parsed_script and parsed_script[0] or {}
    task = Task(root_dir=data['root_dir'], file_mask=data.get('mask'))
    for rule in data['rules']:
        task.add_rule(Rule(**rule))

    return task
开发者ID:tsyganov-ivan,项目名称:PiterPy3,代码行数:8,代码来源:__init__.py


示例4: save_task

def save_task():
	new_task = Task(request.form['title']) #string from dict
	notes = request.form['notes'] #string from dict
	new_task.notes = notes #object new_task with attribute notes
	model.add(new_task)
	model.save_all()

	# return "Saved, theoretically"
	return redirect(url_for("home"))
开发者ID:laurenstill,项目名称:flask_todolist,代码行数:9,代码来源:webapp.py


示例5: addTask

def addTask(phone, url, periods, sendDateTimeList, smsType, smsSender):
    task = Task(phone=phone,
                url=url,
                periods=map(
                int, periods.split(';')),
                sendDateTimeList=[datetime.strptime(dateString.strip(), settings.TIMEFORMAT) for dateString in sendDateTimeList.split(';') if dateString.strip()],
                smsType=smsType.strip(),
                smsSender=smsSender.strip())
    task.put()
开发者ID:jt1,项目名称:weatherforcastsms,代码行数:9,代码来源:utils.py


示例6: post

    def post(self):
        task = Task(name=self.request.get('name'),
                    done=self.request.get('done'),
                    progress=int(self.request.get('progress')),
                    questKey=ndb.Key(Quest, int(self.request.get('questId'))))

        task.put()
        task = task.to_dct()
        self.response.write(task['id'])
开发者ID:DesenvolvedoresGoogle,项目名称:TaskKilla,代码行数:9,代码来源:task_handles.py


示例7: log_tasks

def log_tasks(user, subject, body):
    details = {'user': user}
    date = parse_date(subject)
    if date:
        details['date'] = date - timedelta(hours=user.timezone)

    for task in parse_body(body):
        details['description'] = task
        Task.create(**details)
开发者ID:TeachBoost,项目名称:ansible,代码行数:9,代码来源:email.py


示例8: create_task

def create_task(name , script_group_id , server_group_id) :
    try :
        session = Session()
        new_task = Task(script_group_id , server_group_id , name)
        task_id = new_task.save_return_id()
        if task_id <= 0 :
            return {"status":-1 , "val":None }
        return {"status":0 , "val":task_id}
    except Exception ,msginfo :
        return {"status":-1 , "val":msginfo}
开发者ID:fikgol,项目名称:vulcan,代码行数:10,代码来源:helper.py


示例9: post

 def post(self):
     name = self.request.get("name")
     url = self.request.get("url")
     if (not name or not url):
         self.response.out.write("name and url required")
         return
     # name and url ok
     new_task = Task(name = name, url = url.strip())
     new_task.put()
     #self.response.out.write('<p>Task added OK</p><p><a href="/">back</a></p>')
     self.redirect("/list")
开发者ID:srijib,项目名称:gae,代码行数:11,代码来源:main.py


示例10: test_delete_item

    def test_delete_item(self):
        j = JSon(config.backend_json['filename'])

        t = Task('new task')
        t.id = 3
        t.category_id=1

        key = 'Task.3'

        j.delete_item(t)
        j.commit()

        self.assertNotIn(key, j.data.keys())
开发者ID:franckv,项目名称:ptime,代码行数:13,代码来源:test_json.py


示例11: test_encoder

    def test_encoder(self):
        p = Project('test')
        p.id = 1
        c = Category('test')
        c.id = 2
        c.project_id = p.id
        t = Task('test')
        t.id = 3
        t.category_id = c.id

        self.assertIsNotNone(json.dumps(p, cls=ModelEncoder))
        self.assertIsNotNone(json.dumps(c, cls=ModelEncoder))
        self.assertIsNotNone(json.dumps(t, cls=ModelEncoder))
开发者ID:franckv,项目名称:ptime,代码行数:13,代码来源:test_json.py


示例12: create_task

def create_task():
    print 'Creating a new task:'
    sparql_endpoint = raw_input('Source SPARQL endpoint: ')
    graph = raw_input('Named graph from Virtuoso in which data is going to be stored: ')
    task = Task()
    task.endpoint = sparql_endpoint
    task.graph = graph
    task.offset = 0
    task.start_time = datetime.now()
    session.add(task)
    session.commit()
    print 'Launching task...'
    launch_task.delay(task.id)
开发者ID:memaldi,项目名称:LDClassifier-python,代码行数:13,代码来源:main.py


示例13: p_task

    def p_task(self, p):
        '''task : with in rule_list
                | in rule_list'''
        if len(p) == 4:
            _, file_mask, root_dir, rules = p
        else:
            _, root_dir, rules = p
            file_mask = None

        task = Task(root_dir, file_mask)
        for rule in rules:
            task.add_rule(rule)

        p[0] = task
开发者ID:tsyganov-ivan,项目名称:PiterPy3,代码行数:14,代码来源:parser.py


示例14: get

 def get(self):
     from google.appengine.api import taskqueue
     tasks = Task.all().fetch(1000)
     for task in tasks:
         if task.enabled:
             taskqueue.add(url='/work', method="GET", params={"key": task.key()})
     self.response.out.write('Queued all tasks complete.')
开发者ID:srijib,项目名称:gae,代码行数:7,代码来源:main.py


示例15: get_all_direct_subtasks

def get_all_direct_subtasks(domain_identifier,
                            root_task=None,
                            limit=100,
                            user_identifier=None):
    """
    Returns all direct subtasks of a |root_task| in the given domain.
    If no |root_task| is specified, then all root tasks of the
    domain will be returned.

    This function returns at most |limit| tasks.

    Args:
        domain_identifier: The domain identifier string
        root_task: An instance of the Task model
        limit: The maximum number of tasks that will be returned
        user_identifier: Optional user identifier. If provided, the tasks
            will be sorted on their active state for that user.

    Returns:
        A list of at most |limit| task instances of the domain,
        who are all direct descendants of |root_task|, or are
        all root task if no specific |root_task| is specified.
        The tasks are ordered on completion state, and if a |user_identifier|
        is provided, also on active state.
    """
    query = Task.all().\
        ancestor(Domain.key_from_name(domain_identifier)).\
        filter('parent_task = ', root_task)
    tasks = query.fetch(limit)
    _sort_tasks(tasks, user_identifier=user_identifier)
    return tasks
开发者ID:wadevries,项目名称:sps,代码行数:31,代码来源:api.py


示例16: get

 def get(self, *args, **kwargs):
     """ order: p, s, t default desc p_, s_, t_ - asc
     """
     # get args
     status = self.get_args('s') or self.get_cookie('status', 'unsolved')
     order = self.get_args('o') or self.get_cookie('order', 'p')  # _o - desc, o_ - asc
     page = self.get_args('p', 1)
     # 记录状态
     self.set_cookie('status', status)
     self.set_cookie('order', order)
     self.set_cookie('cur_auth', str(self.auth.id))
     # set order_by
     if order not in self._order.keys():
         order = 'p'
     order_by = self._order.get(order)
     page = int(page)
     pros = Auth.find_user_projects(uid=self.user.id)
     where = dict(
         uid=self.user.id,
         pid=self.pid,
         status=status
     )
     if status != 'assigned':
         tasks, num = Task.find_project_tasks(
             page=page,
             order_by=order_by,
             get_num=True,
             **where)
         paginator = Paginator(page, num, Task._per_page)
     else:
         tasks = Task.assigned_tasks(
             user_id=self.user.id,
             order_by=order_by,
             pid=self.pid,
         )
         paginator = None
     unread_num = Message.unread_num(user_id=self.user.id)
     return self.render(
         'task-home.html',
         cur_pro=self.auth,
         pros=pros,
         tasks=tasks,
         status=status,
         order=order,
         page=page,
         paginator=paginator,
         unread_num=unread_num)
开发者ID:Geew,项目名称:issue-task,代码行数:47,代码来源:view.py


示例17: txn

 def txn():
     task = api.get_task(domain_identifier, task_identifier)
     if not task:
         logging.error("Task '%s/%s' does not exist", domain_identifier, task_identifier)
         return
     index = TaskIndex.get_by_key_name(task_identifier, parent=task)
     if not index:
         index = TaskIndex(parent=task, key_name=task_identifier)
     # Get all subtasks. The ancestor queries are strongly
     # consistent, so when propagating upwards through the
     # hierarchy the changes are reflected.
     subtasks = list(Task.all().ancestor(domain_key).filter("parent_task =", task.key()))
     if not subtasks:  # atomic task
         task.derived_completed = task.completed
         task.derived_size = 1
         task.derived_atomic_task_count = 1
         task.derived_has_open_tasks = task.open()
         assignee_identifier = task.assignee_identifier()
         if assignee_identifier:
             index.assignees = [assignee_identifier]
             if not DEV_SERVER:
                 # Uses a multi entity group transaction to get the name
                 # of the assignee. This is cached in the record for
                 # quick descriptions.
                 assignee = api.get_user(assignee_identifier)
                 name = assignee.name if assignee else "<Missing>"
             else:
                 name = "temp"
             task.derived_assignees[task.assignee_identifier()] = {
                 "id": task.assignee_identifier(),
                 "name": name,
                 "completed": int(task.is_completed()),
                 "all": 1,
             }
     else:  # composite task
         task.derived_completed = all(t.is_completed() for t in subtasks)
         task.derived_size = 1 + sum(t.derived_size for t in subtasks)
         task.derived_atomic_task_count = sum(t.atomic_task_count() for t in subtasks)
         task.derived_has_open_tasks = any(t.has_open_tasks() for t in subtasks)
         # Compute derived assignees, and sum the total of all
         # their assigned and completed subtasks.
         assignees = {}
         for subtask in subtasks:
             subtask_assignees = subtask.derived_assignees
             for id, record in subtask_assignees.iteritems():
                 if not id in assignees:
                     assignees[id] = {"id": id, "name": record["name"], "completed": 0, "all": 0}
                 assignees[id]["completed"] += record["completed"]
                 assignees[id]["all"] += record["all"]
         task.derived_assignees = assignees
         index.assignees = list(assignees.iterkeys())
     task.put()
     index.completed = task.is_completed()
     index.has_open_tasks = task.has_open_tasks()
     index.atomic = task.atomic()
     index.put()
     # Propagate further upwards
     if task.parent_task_identifier():
         UpdateTaskCompletion.enqueue(domain_identifier, task.parent_task_identifier(), transactional=True)
开发者ID:troberti,项目名称:sps,代码行数:59,代码来源:workers.py


示例18: get_task

def get_task(domain, task):
    """Gets a task in a domain.

    Args:
        domain: The domain identifier
        task: The task key id or name. Can either be an int
            or a string.

    Returns:
        A task instance or None if no task exists.
    """
    domain_key = Domain.key_from_name(domain)
    try:
        task_id = int(task)
        return Task.get_by_id(task_id, parent=domain_key)
    except ValueError:
        return Task.get_by_key_name(task, parent=domain_key)
开发者ID:edrijver,项目名称:sps,代码行数:17,代码来源:api.py


示例19: addRecord

def addRecord(**args):
    session = connectdb()
    cat = session.query(Catagory).filter_by(name=args['cat'])
    if cat.all():
        catobj = cat.one()
    else:
        catobj = Catagory(args['cat'])
    taskobj = Task(args['task'])
    taskobj.cat = catobj
#    if True:
#        session.add(task)
#    date = args['date'].today()
    record = Record(args['date'], args['start_time'], args['big_or_not'])
    record.task = taskobj
    session.merge(record) # cat and task will save/update automatically and cascade due to the session's default setting?
    my_db_commit(session)
    session.close()
开发者ID:cmal,项目名称:mygtd,代码行数:17,代码来源:controller.py


示例20: txn

 def txn():
     query = Task.all().ancestor(Domain.key_from_name(domain)).\
         filter('number_of_subtasks =', 0).\
         filter('completed =', False).\
         filter('assignee =', None).\
         order('-time')
     return _group_tasks(query.fetch(50),
                         complete_hierarchy=True,
                         domain=domain)
开发者ID:edrijver,项目名称:sps,代码行数:9,代码来源:api.py



注:本文中的model.Task类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python model.User类代码示例发布时间:2022-05-27
下一篇:
Python model.Tag类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap