本文整理汇总了Python中Job.Job.selectBy方法的典型用法代码示例。如果您正苦于以下问题:Python Job.selectBy方法的具体用法?Python Job.selectBy怎么用?Python Job.selectBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Job.Job
的用法示例。
在下文中一共展示了Job.selectBy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_jobs
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def get_jobs(self, name, version=None, dist=None, arch=None):
"""Dump a job status"""
if version:
pkgs = Package.selectBy(name=name, version=version)
else:
pkgs = Package.selectBy(name=name)
if not pkgs.count():
return []
retjobs = []
if dist and arch:
for pkg in pkgs:
retjobs.extend(Job.selectBy(package=pkg, dist=dist, arch=arch))
elif dist:
for pkg in pkgs:
retjobs.extend(Job.selectBy(package=pkg, dist=dist))
elif arch:
for pkg in pkgs:
retjobs.extend(Job.selectBy(package=pkg, arch=arch))
else:
for pkg in pkgs:
retjobs.extend(Job.selectBy(package=pkg))
return retjobs
示例2: get_new_jobs
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def get_new_jobs(self):
"""Feed jobs list with waiting jobs and lock them"""
max_new = self.cfg.getint('build', 'max_jobs')
count_current = len(self.jobs)
with self.jobs_locker:
if count_current >= max_new:
return 0
jobs = []
for dist in Dists().dists:
jobs.extend(Job.selectBy(status=JobStatus.WAIT, dist=dist.name, arch=dist.arch)[:max_new])
count_new = 0
for job in jobs:
# Look for higher versions ?
if self.cfg.getboolean('build', 'build_more_recent'):
packages = Package.selectBy(name=job.package.name)
candidate_packages = []
candidate_packages.extend(packages)
candidate_packages.sort(cmp=Package.version_compare)
candidate_packages.reverse()
newjob = None
# so there are packages with higher version number
# try to see if there's a job for us
for cpackage in candidate_packages:
candidate_jobs = []
candidate_jobs.extend(Job.selectBy(package=cpackage, dist=job.dist, arch=job.arch))
for cjob in candidate_jobs:
if newjob and newjob != cjob and cjob.status == JobStatus.WAIT:
cjob.status = JobStatus.GIVEUP
elif cjob.status == JobStatus.WAIT:
newjob = cjob
job = newjob
# We have to check because it might have changed
# between our first select and the build_more_recent stuffs
if not job or job.status != JobStatus.WAIT:
continue
# Check dependencies
if not job.is_allowed_to_build():
continue
job.status = JobStatus.WAIT_LOCKED
job.host = socket.gethostname()
self.jobs.append(job)
count_new += 1
count_current += 1
if count_current >= max_new:
break
return count_new
示例3: requeue_job
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def requeue_job(self, job_id):
"""Requeue a failed job"""
if Job.selectBy(id=job_id).count() == 0:
RebuilddLog.error("There is no job related to %s that is in the job list" % job_id)
return False
job = Job.selectBy(id=job_id)[0]
if job.status in FailedStatus:
job.status = JobStatus.WAIT
job.host = ""
return True
示例4: GET_buildstats
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def GET_buildstats(self, distarch=None):
graph = self.graph_init()
if distarch == "/":
graph.title = "Build status"
jobs = Job.selectBy()
else:
dindex = distarch.rindex("/")
graph.title = "Build status for %s" % distarch[1:]
jobs = Job.selectBy(arch=distarch[dindex+1:], dist=distarch[1:dindex])
graph.setData(self.compute_stats(jobs))
tmp = tempfile.TemporaryFile()
graph.draw(tmp)
tmp.seek(0)
return tmp.read()
示例5: fix_jobs
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def fix_jobs(self, print_result=True):
"""If rebuildd crashed, reset jobs to a valid state"""
jobs = []
jobs.extend(Job.selectBy(host=socket.gethostname(), status=JobStatus.WAIT_LOCKED))
jobs.extend(Job.selectBy(host=socket.gethostname(), status=JobStatus.BUILDING))
for job in jobs:
if print_result:
print "I: Fixing job %s (was %s)" % (job.id, JobStatus.whatis(job.status))
job.host = None
job.status = JobStatus.WAIT
job.build_start = None
job.build_end = None
return True
示例6: add_job
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def add_job(self, name, version, priority, dist, mailto=None, arch=None):
"""Add a job"""
if not arch:
arch = self.cfg.arch[0]
if not Dists().get_dist(dist, arch):
RebuilddLog.error("Couldn't find dist/arch in the config file for %s_%s on %s/%s, don't adding it" \
% (name, version, dist, arch))
return False
pkgs = Package.selectBy(name=name, version=version)
if pkgs.count():
# If several packages exists, just take the first
pkg = pkgs[0]
else:
# Maybe we found no packages, so create a brand new one!
pkg = Package(name=name, version=version, priority=priority)
jobs_count = Job.selectBy(package=pkg, dist=dist, arch=arch, mailto=mailto, status=JobStatus.WAIT).count()
if jobs_count:
RebuilddLog.error("Job already existing for %s_%s on %s/%s, don't adding it" \
% (pkg.name, pkg.version, dist, arch))
return False
job = Job(package=pkg, dist=dist, arch=arch)
job.status = JobStatus.WAIT
job.arch = arch
job.mailto = mailto
log = Log(job=job)
RebuilddLog.info("Added job for %s_%s on %s/%s for %s" \
% (name, version, dist, arch, mailto))
return True
示例7: GET_package
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def GET_package(self, package=None):
graph = self.graph_init()
if package == "/":
graph.title = "Build status"
jobs = Job.selectBy()
else:
dindex = package.rindex("/")
graph.title = "Build status for %s" % package[1:]
pkg = Package.selectBy(version=package[dindex+1:], name=package[1:dindex])[0]
jobs = Job.selectBy(package=pkg)
graph.setData(self.compute_stats(jobs))
tmp = tempfile.TemporaryFile()
graph.draw(tmp)
tmp.seek(0)
return tmp.read()
示例8: add_deps
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def add_deps(self, job_id, dependency_ids):
if Job.selectBy(id=job_id).count() == 0:
RebuilddLog.error("There is no job related to %s that is in the job list" % job_id)
return False
job = Job.selectBy(id=job_id)[0]
deps = []
for dep in dependency_ids:
if Job.selectBy(id=dep).count() == 0:
RebuilddLog.error("There is no job related to %s that is in the job list" % dep)
return False
dep_job = Job.selectBy(id=dep)[0]
deps.append(dep_job)
job.add_deps(deps)
return True
示例9: GET
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def GET(self, jobid=None):
job = Job.selectBy(id=jobid)[0]
try:
with open(job.logfile, "r") as build_logfile:
build_log = build_logfile.read()
except IOError, error:
build_log = job.log.text
示例10: get_all_jobs
# 需要导入模块: from Job import Job [as 别名]
# 或者: from Job.Job import selectBy [as 别名]
def get_all_jobs(self, **kwargs):
jobs = []
jobs.extend(Job.selectBy(**kwargs))
return jobs