本文整理汇总了Python中jobs.models.Job.all方法的典型用法代码示例。如果您正苦于以下问题:Python Job.all方法的具体用法?Python Job.all怎么用?Python Job.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jobs.models.Job
的用法示例。
在下文中一共展示了Job.all方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_do_work
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def test_do_work(self):
response = self.client.post(reverse('jobs.start'), {
'job_name': 'counter'
})
json_response = simplejson.loads(response.content)
self.assert_json_success(json_response)
job_key = json_response['job_key']
# work the counter three times:
response = self.client.post(reverse('jobs.work'), {
'job_key': job_key
})
json_response = simplejson.loads(response.content)
self.assert_json_success(json_response)
job = Job.all().filter('job_name =', 'counter')[0]
self.assertEqual(simplejson.loads(job.result), {'count':1})
self.assertEqual(json_response['finished'], False)
response = self.client.post(reverse('jobs.work'), {
'job_key': job_key
})
json_response = simplejson.loads(response.content)
self.assert_json_success(json_response)
job = Job.all().filter('job_name =', 'counter')[0]
self.assertEqual(simplejson.loads(job.result), {'count':2})
self.assertEqual(json_response['finished'], False)
response = self.client.post(reverse('jobs.work'), {
'job_key': job_key
})
json_response = simplejson.loads(response.content)
self.assert_json_success(json_response)
job = Job.all().filter('job_name =', 'counter')[0]
self.assertEqual(simplejson.loads(job.result), {'count':3})
self.assertEqual(json_response['finished'], True)
示例2: test_start
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def test_start(self):
response = self.client.post(reverse('jobs.start'), {
'job_name': 'counter'
})
json_response = simplejson.loads(response.content)
self.assert_json_success(json_response)
job = Job.all().filter('job_name =', 'counter')[0]
self.assertEqual(json_response['job_key'], str(job.key()))
self.assertEqual(job.result, None)
示例3: rss
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def rss(request):
jobs = Job.all().filter('status =', 'published').order('-published_at').fetch(20)
jobs_published_at = [job.published_at for job in jobs]
if jobs_published_at:
pub_date = max(jobs_published_at)
else:
pub_date = None
return render_to_response('rss.xml',
{'jobs': jobs,
'host': request.get_host(),
'pub_date': pub_date},
mimetype='application/rss+xml')
示例4: check_queued
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def check_queued(request):
job = Job.all().filter('status =', 'queued').order('queued_at').fetch(1)
if job:
job = job[0] # fetch() returns list of items
result = urlfetch.fetch(job.owner_profile_url)
if result.status_code == 200:
try: # if owner's profile contents code, this will pass silently
result.content.index(job.code)
job.publish()
job.put()
return HttpResponse('Published')
except ValueError:
pass
job.fail()
job.put()
return HttpResponse('Failed')
else:
return HttpResponse('No queued jobs.')
示例5: my
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def my(request):
jobs = Job.all().filter('owner =', users.get_current_user()).order('-created_at')
return _custom_render_to_response('my_jobs.html', {'jobs': jobs, 'title': 'My jobs'})
示例6: reap_dead_jobs
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def reap_dead_jobs():
q = Job.all().filter("started <",
datetime.datetime.now() - timedelta(days=2))
for job in q:
job.delete()
示例7: teardown_data
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import all [as 别名]
def teardown_data():
for ob in Job.all():
ob.delete()
jobs._reset_registry()