当前位置: 首页>>代码示例>>Python>>正文


Python model.Task类代码示例

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


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


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