本文整理汇总了Python中models.Job类的典型用法代码示例。如果您正苦于以下问题:Python Job类的具体用法?Python Job怎么用?Python Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Job类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: post
def post(self, request, *args, **kwargs):
form = JobForm(request.POST, request.FILES)
if form.is_valid():
now = datetime.datetime.now()
name = request.POST['name']
description = request.POST['description']
interval = request.POST['interval']
interval_options = request.POST['interval_options']
arguments = request.POST['arguments']
active = False
try:
request.POST['active']
active = True
except:
pass
file = request.FILES['file']
file_content = file.read()
file_name = str(now.year) + str(now.month) + str(now.day) + str(now.hour) + str(now.minute) + str(now.second) + str(now.microsecond) + name.replace(' ', '-') + '.py'
f = open(BASE_DIR + '/job_files/' + file_name, 'w')
f.write(file_content)
f.close()
#Save job
new_job = Job(name=name, description=description, interval=interval, interval_options=interval_options, arguments=arguments, active=active, file_name=file_name)
new_job.save()
res = 'Job created'
return render_to_response(self.template_name, locals(), context_instance=RequestContext(request))
开发者ID:trencube,项目名称:SchPark,代码行数:30,代码来源:views.py
示例2: bpusher_PostJob
def bpusher_PostJob(request):
jsonData = json.loads(request.body)
try:
destination = Destination.objects.get(name=jsonData['job']['destination'])
except ObjectDoesNotExist:
status = http_NOT_FOUND
return HttpResponse(json.dumps({'message': 'Destination not found'}), status=status, content_type='application/json')
job = Job()
job.name = jsonData['job']['name']
job.input_name = jsonData['job']['input_name']
job.system_path = jsonData['job']['system_path']
job.input_path = jsonData['job']['input_path']
job.destination = destination
job.priority = jsonData['job']['priority']
job.status = 'Q' # Queue
job.save()
response = {"job": {"id": job.id, "name": job.name}}
#
# La unica respuesta para esto es OK
status = http_POST_OK
return HttpResponse(json.dumps(response), status=status, content_type='application/json')
开发者ID:npajoni,项目名称:tubuceta,代码行数:28,代码来源:views.py
示例3: imen_PostJob
def imen_PostJob(request):
jsonData = json.loads(request.body)
try:
preset = ThumbPreset.objects.get(name=jsonData['job']['thumb_preset'])
except ObjectDoesNotExist:
status = http_NOT_FOUND
return HttpResponse(json.dumps({'message': 'ThumbPreset not found'}), status=status, content_type='application/json')
job = Job()
job.input_filename = jsonData['job']['input_filename']
job.input_path = jsonData['job']['input_path']
job.basename = jsonData['job']['basename']
job.thumb_preset = preset
job.priority = jsonData['job']['priority']
job.output_path = jsonData['job']['output_path']
job.status = 'Q' # Queue
job.save()
response = {"job": {"id": job.id}}
#
# La unica respuesta para esto es OK
status = http_POST_OK
return HttpResponse(json.dumps(response), status=status, content_type='application/json')
开发者ID:emilianobilli,项目名称:tarecho,代码行数:28,代码来源:views.py
示例4: test_job_should_emit_results_for_all_urls
def test_job_should_emit_results_for_all_urls(self):
first_domain = Domain("http://example.com")
first_img_url = Image("http://example.com/1.png")
second_img_url = Image("http://example.com/2.png")
third_img_url = Image("http://example.com/3.png")
first_domain.images.extend([first_img_url, second_img_url, third_img_url])
second_domain = Domain("http://example.com/2")
fourth_img_url = Image("http://example.com/4.png")
second_domain.images.extend([fourth_img_url])
job = Job([first_domain,second_domain])
self.assertEqual(job.get_results(), {
"id": job.id,
"domains":{
"http://example.com":[
"http://example.com/1.png",
"http://example.com/2.png",
"http://example.com/3.png"
],
"http://example.com/2":[
"http://example.com/4.png"
]
}
})
开发者ID:creade,项目名称:pl-crawler,代码行数:27,代码来源:tests.py
示例5: add_job
def add_job(request):
try:
form = JobForm(request.POST or None)
if form.is_valid():
required_skills = set(form.cleaned_data["required_skills"])
optional_skills = set(form.cleaned_data["optional_skills"]) - required_skills
with transaction.atomic():
employer = Employer.objects.get(user=request.user)
job = Job(
employer=employer,
description=form.cleaned_data["description"],
category=form.cleaned_data["category"],
years_of_experience=form.cleaned_data["years_of_experience"],
other=form.cleaned_data["other"],
)
job.save()
for skill in required_skills:
skill = RequiredJobSkill(job=job, skill=skill)
skill.save()
if optional_skills:
for skill in optional_skills:
skill = OptionalJobSkill(job=job, skill=skill)
skill.save()
match_job.delay(job.id)
messages.success(request, "Job saved successfully. You'll receive matching candidates soon")
return HttpResponseRedirect("/")
return render(request, "jobs/add_job.html", {"form": form})
except Exception, e:
logging.exception(e)
return server_error(request)
开发者ID:evanson,项目名称:job_matcher,代码行数:31,代码来源:views.py
示例6: get
def get(self, job_id):
job = Job.get_by_key_name(job_id)
if job and job.state != DONE and job.active == True:
job.updated_at = datetime.now()
job.state = DONE
job.put()
# update the email
email = job.email
email.updated_at = datetime.now()
email.put()
# count the number of jobs attached to this flyer
job_query = Job.all()
job_query.filter("flyer =", job.flyer)
job_query.filter("active =", True)
total_jobs = job_query.count()
# count the number of jobs done so far
job_query = Job.all()
job_query.filter("flyer =", job.flyer)
job_query.filter("active =", True)
job_query.filter("state =", DONE)
done_jobs = job_query.count()
# write out
self.response.out.write(template.render("templates/finish.html",
{"total": total_jobs,
"done": done_jobs}))
else:
self.error(404)
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:28,代码来源:flyer.py
示例7: new_job
def new_job():
if not g.site.domain == g.user:
abort(403)
j = Job()
if request.method == "POST":
portfolio = Portfolio.objects.get(site=g.site.domain)
job_name = request.form.get("name")
slugs = [__j.slug for __j in Job.objects.filter(site=g.site.domain)]
counter = 1
slug = slugify(job_name)
__slug = slug
while __slug in slugs:
counter += 1
__slug = "%s_%d" % (slug, counter)
j.slug = __slug
j.name = job_name
j.site = g.site.domain
j.categories = [ c.strip() for c in request.form.get("categories").split(",") ]
j.intro = request.form.get("intro")
j.description = request.form.get("description")
j.slides = []
texts = request.form.getlist("text")
image_urls = request.form.getlist("image_url")
captions = request.form.getlist("caption")
caption_links = request.form.getlist("caption_link")
for text, image_url, caption, caption_link in zip(texts, image_urls, captions, caption_links):
if text or image_url:
j.slides.append(Slide(text=text, image_url=image_url, caption=caption, caption_link=caption_link))
j.save()
portfolio.jobs.append(j)
portfolio.save()
return redirect(url_for(".job", slug=j.slug))
return render_template("edit_job.html", job=j)
开发者ID:abal09,项目名称:samklang,代码行数:34,代码来源:portfolio.py
示例8: post
def post(self, job_id):
job = Job.get_by_key_name(job_id)
# make sure the job is recent
if not(job.active):
self.error(404)
email = job.email
email.enable = False
email.updated_at = datetime.datetime.now()
email.put()
# find the email-club join
join_query = EmailToClub.all()
join_query.filter("email =", email)
joins = join_query.fetch(20)
# do the delete
for join in joins:
join.enable = False
join.updated_at = datetime.now()
join.put()
# mark all the jobs inactive
job_query = Job.all()
job_query.filter("email =", email)
job_query.filter("active =", True)
jobs = job_query.fetch(20)
for job in jobs:
job.active = False
job.put()
self.response.out.write(template.render("templates/sorry.html", {}))
开发者ID:thenoviceoof,项目名称:flyer-poke,代码行数:27,代码来源:flyer.py
示例9: test_job_should_emit_status_for_all_urls
def test_job_should_emit_status_for_all_urls(self):
first_domain = Domain("http://example.com")
first_domain.crawled = True
second_domain = Domain("http://example.com/2")
job = Job([first_domain,second_domain])
self.assertEqual(job.get_status()["completed"], 1)
self.assertEqual(job.get_status()["inprogress"], 1)
开发者ID:creade,项目名称:pl-crawler,代码行数:8,代码来源:tests.py
示例10: schedule
def schedule(function, args = None, kwargs = None,
run_after= None, meta = None):
"""Schedule a tast for execution.
"""
job = Job(
name=full_name(function),
args=dumps(args or []), kwargs=dumps(kwargs or {}),
meta=dumps(meta or {}), scheduled=run_after)
job.save()
return job
开发者ID:MechanisM,项目名称:django-async,代码行数:10,代码来源:api.py
示例11: create
def create():
post_data = get_post_data()
post_data['lead_id'] = parse_endpoint(post_data['lead'], 'leads')
# saves the job
job = Job()
job.build(post_data)
job.status = 'CREATED'
job.unique_id = Job.generate_unique_id()
if job.put():
# enqueue job to be sent to townflix
_enqueue_job_creation_message(job)
pprint.pprint('=== JOB CREATED')
# mark the lead as converted
lead = job.lead.get()
lead.status = 'CONVERTED'
lead.put()
create_activity('LEAD_CONVERTED', lead=lead, job=job)
create_activity('JOB_CREATED', lead=lead, job=job)
# send a message to property owner
_enqueue_job_create_message(job)
# if the lead has been sent by someone
if lead.sender_broker is not None:
# send a message to the broker
_enqueue_broker_job_create_message(job)
return jsonify(data=job.to_json()), 201
else:
return jsonify(data=job.error_messages()), 500
开发者ID:armandomiani,项目名称:flask-appengine-bootstrap,代码行数:35,代码来源:jobs.py
示例12: bmanager_post_job
def bmanager_post_job(request):
jsonData =json.loads(request.body)
job = Job()
job.basename = jsonData['job']['basename']
job.format = jsonData['job']['format']
job.input_filename = jsonData['job']['input_filename']
job.input_path = jsonData['job']['input_path']
try:
job.profile = Profile.objects.get(name=jsonData['job']['profile'])
except ObjectDoesNotExist:
status = http_NOT_FOUND
return HttpResponse(json.dumps({'message': 'Profile not found'}), status=status, content_type='application/json')
dest_list = []
destinations = jsonData['job']['destinations']
for destination in destinations:
try:
dest_list.append(Destination.objects.get(name=destination))
#job.destinations.add(Destination.objects.get(name=destination))
except ObjectDoesNotExist:
status = http_NOT_FOUND
return HttpResponse(json.dumps({'message': 'Destination not found'}), status=status,content_type='application/json')
job.save()
job.destinations = dest_list
#job.save()
response = {"job": {"id": job.id, "basename": job.basename}}
status = http_POST_OK
return HttpResponse(json.dumps(response), status=status, content_type='application/json')
开发者ID:npajoni,项目名称:tubuceta,代码行数:34,代码来源:views.py
示例13: main
def main():
while True:
job = Job.get_queue()
if job:
print 'Working on',job['_id']
work(job)
job['is_done'] = True
Job.save(job)
print 'Done'
else:
time.sleep(POLL_TIME)
开发者ID:jittat,项目名称:hcr-web,代码行数:11,代码来源:worker.py
示例14: before_request
def before_request():
g.db = connect_db()
Slot_Conf.set_db(g.db)
Job.set_db(g.db)
TimeInfo.set_db(g.db)
slotStartEnd.set_db(g.db)
Projects.set_db(g.db)
Results.set_db(g.db)
ProjNames.set_db(g.db)
SlotTimes.set_db(g.db)
ProjectTimes.set_db(g.db)
开发者ID:sofiaqiriazi,项目名称:StatisticsApp,代码行数:11,代码来源:statistics.py
示例15: job_add
def job_add(request, event_id, task_id):
event = get_object_or_404(Event, pk=event_id)
task = get_object_or_404(Task, pk=task_id)
#job_user = get_object_or_404(User, pk=user_id)
#if job_user != user:
# return HttpResponseNotAllowed('<h1>Must not add other users!</h1>')
job = Job(event=event, task = task, user = request.user)
job.save()
messages.success(request, _("Took job"))
return HttpResponseRedirect(reverse('event', args=[event.id]))
开发者ID:rangermeier,项目名称:subkoord,代码行数:11,代码来源:views.py
示例16: jobs_post
def jobs_post(request): # FIXME use method POST
job = Job()
for field in PUBLIC_FIELDS:
if field in request.GET:
if field == 'params':
job[field] = json.loads(request[field])
else:
job[field] = request[field]
job.save()
return format_job(job)
开发者ID:marinho,项目名称:london-node-jobs,代码行数:11,代码来源:views.py
示例17: submit
def submit(self, request):
job = Job(query=json.dumps(self.cleaned_data["query"]))
try:
job.save()
except DatabaseError:
raise DatabaseIntegrityError()
if self.cleaned_data["query"]["type"] == "FASTA":
pass
else:
pass
开发者ID:reamdc1,项目名称:OperonEvoDB,代码行数:12,代码来源:forms.py
示例18: getJobInfo
def getJobInfo(dom, company):
'''获取一个职位的招聘信息'''
job_info = {}
type_tr = dom('.jobInfoItems tr:eq(0)')
trtext = type_tr.text()
trtext = trtext.split(u':') if trtext else []
if len(trtext) == 2:
k, v = trtext
v = v.replace('/', ',')
job_info[k] = v
trs = dom('.jobInfoItems tr:gt(1)')
for tr in trs:
tr = pq(tr)
tds = tr('td')
for td in tds:
td = pq(td)
tdtext = td.text().split(u':')
if len(tdtext) == 2:
k, v = tdtext
job_info[k] = v
salary = job_info.get(u'职位月薪')
if salary:
sh = re.search(r'(\d+)-(\d+)', salary)
salary = sh.groups() if sh else (None, None)
else:
salary = (None, None)
quantity = job_info.get(u'招聘人数')
if quantity:
sh = re.search(r'(\d+)', quantity)
quantity = sh.group(0) if sh else None
job = Job()
occ_type = job_info.get(u'职位类别')
occ = Occupational.query.filter(Occupational.type==occ_type).first()
if not occ:
occ = Occupational()
occ.name = 'FILL'
occ.type = occ_type
db.session.add(occ)
job.occupational = occ
job.type = job_info.get(u'工作性质')
job.exp = job_info.get(u'工作经验')
job.manage_exp = job_info.get(u'管理经验')
job.quantity = quantity
job.degree = job_info.get(u'最低学历')
job.salary_low, job.salary_high = salary
job.description = dom('.jobDes').html()
job.etag = ''
return job
开发者ID:Genieliu,项目名称:job-hunter,代码行数:53,代码来源:job_spider.py
示例19: todayStats
def todayStats():
slots = []
#today = time.strftime("%Y-%m-%d")
#weekbefore = (date.today()-timedelta(6)).strftime('%Y-%m-%d')
jobEnds = Job.view('statistics/jobEnds',group_level=3,startkey = [today])
jobStarts = Job.view('statistics/jobStarts',group_level=3,startkey = [today])
slots = Slot_Conf.view('statistics/Slots',startkey = today)
times = TimeInfo.view('statistics/completionTime',group = True, startkey = weekbefore)
data = []
jobsEnded = {}
jobsStarted = {}
for s in slots:
jobsEnded[s.slot] = 0
jobsStarted[s.slot] = 0
for j in jobEnds:
jobsEnded[j['key'][1]]=j['value']
for j in jobStarts:
jobsStarted[j['key'][1]]=j['value']
unfinished = 0
unstarted = 0
unfinished_list = []
unstarted_list = []
completed_list = []
for s in slots:
if(jobsEnded[s.slot]!=len(s.platforms)):
unfinished+=1
unfinished_list.append(s.slot)
if(jobsStarted[s.slot]!=len(s.platforms)):
unstarted+=1
unstarted_list.append(s.slot)
if(jobsStarted[s.slot]==len(s.platforms) and jobsEnded[s.slot]==len(s.platforms)):
completed_list.append(s.slot)
sum = 0
for t in times:
if t['key']==today:
todaymin = t['value']['min']
sum = sum - (t['value']['max'] - t['value']['min'])
sum = sum + (t['value']['max'] - t['value']['min'])
avgcompletion = sum/6
data = []
all_list = unfinished_list+unstarted_list+completed_list
data.append({"total":len(slots),"all":all_list,"finished":len(slots)-unfinished,"unfinished":unfinished,"unstarted":unstarted,"todaymin":todaymin,"avgcompletion":avgcompletion,"listofunfinished":unfinished_list,"listofunstarted":unstarted_list,"listofcompleted":completed_list})
data =json.dumps(data)
return data
开发者ID:sofiaqiriazi,项目名称:StatisticsApp,代码行数:52,代码来源:statistics.py
示例20: schedule
def schedule(function, args = None, kwargs = None,
priority = 5, run_after= None, meta = None):
"""Schedule a tast for execution.
"""
# Too many arguments
# pylint: disable=R0913
job = Job(
name=full_name(function),
args=dumps(args or []), kwargs=dumps(kwargs or {}),
meta=dumps(meta or {}), scheduled=run_after,
priority=priority)
job.save()
return job
开发者ID:DjNero,项目名称:django-async,代码行数:13,代码来源:api.py
注:本文中的models.Job类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论