當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。