本文整理汇总了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'
示例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
示例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
示例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"))
示例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()
示例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'])
示例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)
示例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}
示例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")
示例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())
示例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))
示例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)
示例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
示例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.')
示例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