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


Python Job.all方法代码示例

本文整理汇总了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)
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:37,代码来源:tests.py

示例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)
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:12,代码来源:tests.py

示例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')
开发者ID:maxnik,项目名称:jobsforhackers,代码行数:14,代码来源:views.py

示例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.')
开发者ID:maxnik,项目名称:jobsforhackers,代码行数:20,代码来源:views.py

示例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'})
开发者ID:maxnik,项目名称:jobsforhackers,代码行数:5,代码来源:views.py

示例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()
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:7,代码来源:views.py

示例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()
开发者ID:BubbleTouchSoftware,项目名称:chirpradio,代码行数:6,代码来源:tests.py


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