本文整理汇总了Python中osci.job.Job.getAllWhere方法的典型用法代码示例。如果您正苦于以下问题:Python Job.getAllWhere方法的具体用法?Python Job.getAllWhere怎么用?Python Job.getAllWhere使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osci.job.Job
的用法示例。
在下文中一共展示了Job.getAllWhere方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def test_delete(self):
db = DB('sqlite://')
db.create_schema()
job = Job(change_num="change_num", project_name="project")
with db.get_session() as session:
session.add(job)
job.db = db
jobs = Job.getAllWhere(db)
self.assertEqual(len(jobs), 1)
Job.deleteWhere(db)
jobs = Job.getAllWhere(db)
self.assertEqual(len(jobs), 0)
示例2: get_jobs
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def get_jobs(self):
ret_list = []
collectingJobs = Job.getAllWhere(self.jobQueue.db,
state=constants.COLLECTING)
for job in collectingJobs:
ret_list.append(job)
return ret_list
示例3: func_failures
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def func_failures(options, queue):
table = PrettyTable(["Project", "Change", "State", "Result", "Age",
"Duration", "URL"])
table.align = 'l'
now = time.time()
all_jobs = Job.getAllWhere(queue.db)
for job in all_jobs:
if not job.result or (job.result != 'Failed' and
job.result.find('Aborted') != 0):
continue
updated = time.mktime(job.updated.timetuple())
age_hours = (now - updated) / 3600
if options.recent:
if age_hours > int(options.recent):
continue
age = '%.02f' % (age_hours)
duration = '-'
if job.test_started and job.test_stopped:
started = time.mktime(job.test_started.timetuple())
stopped = time.mktime(job.test_stopped.timetuple())
duration = "%.02f"%((stopped - started)/3600)
table.add_row([job.project_name, job.change_num,
constants.STATES[job.state], job.result, age,
duration, job.logs_url])
return str(table)
示例4: processResults
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def processResults(self):
allJobs = Job.getAllWhere(self.db, state=constants.RUNNING)
self.log.info('%d jobs running...'%len(allJobs))
for job in allJobs:
if job.isRunning(self.db):
continue
job.update(self.db, state=constants.COLLECTING)
self.log.info('Tests for %s are done! Collecting'%job)
示例5: func_show
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def func_show(options, queue):
table = PrettyTable()
table.add_column('Key', ['Project name', 'Change num', 'Change ref',
'state', 'created', 'Commit id', 'Node id',
'Node ip', 'Result', 'Logs', 'Report',
'Updated', 'Gerrit URL'])
job = Job.getAllWhere(queue.db, change_ref=options.change_ref)[0]
url = 'https://review.openstack.org/%s'%job.change_num
table.add_column('Value',
[job.project_name, job.change_num, job.change_ref,
constants.STATES[job.state], job.created,
job.commit_id, job.node_id, job.node_ip,
job.result, job.logs_url, job.report_url,
job.updated, url])
table.align = 'l'
return str(table)
示例6: func_list
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def func_list(options, queue):
table = PrettyTable(["Project", "Change", "State", "IP", "Result",
"Age (hours)", "Duration"])
table.align = 'l'
now = time.time()
all_jobs = Job.getAllWhere(queue.db)
state_dict = {}
result_dict = {}
if options.states and len(options.states) > 0:
states = options.states.split(',')
else:
states = None
for job in all_jobs:
updated = time.mktime(job.updated.timetuple())
age_hours = (now - updated) / 3600
if options.recent:
if age_hours > int(options.recent):
continue
state_count = state_dict.get(constants.STATES[job.state], 0) + 1
state_dict[constants.STATES[job.state]] = state_count
result_count = result_dict.get(job.result, 0)+1
result_dict[job.result] = result_count
if states and constants.STATES[job.state] not in states:
continue
if job.node_id:
node_ip = job.node_ip
else:
node_ip = '(%s)'%job.node_ip
age = '%.02f' % (age_hours)
duration = '-'
if job.test_started and job.test_stopped:
started = time.mktime(job.test_started.timetuple())
stopped = time.mktime(job.test_stopped.timetuple())
if started < stopped:
duration = "%.02f"%((stopped - started)/3600)
table.add_row([job.project_name, job.change_ref,
constants.STATES[job.state], node_ip, job.result,
age, duration])
output_str = str(state_dict)+"\n"
output_str = output_str + str(result_dict)+"\n"
output_str = output_str + str(table)
return output_str
示例7: func_show
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def func_show(options, queue):
output_str = ''
jobs = Job.getAllWhere(queue.db, change_ref=options.change_ref)
for job in jobs:
table = PrettyTable()
table.add_column('Key', ['ID', 'Project name', 'Change num', 'Change ref',
'state', 'created', 'Commit id', 'Node id',
'Node ip', 'Result', 'Logs', 'Report',
'Updated', 'Gerrit URL', 'Failures'])
url = 'https://review.openstack.org/%s'%job.change_num
table.add_column('Value',
[job.id, job.project_name, job.change_num, job.change_ref,
constants.STATES[job.state], job.created,
job.commit_id, job.node_id, job.node_ip,
job.result, job.logs_url, job.report_url,
job.updated, url, job.failed])
table.align = 'l'
output_str = output_str + str(table)+'\n'
return output_str
示例8: postResults
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def postResults(self):
allJobs = Job.getAllWhere(self.db, state=constants.COLLECTED)
self.log.info('%d jobs ready to be posted...'%len(allJobs))
for job in allJobs:
if job.result.find('Aborted') == 0:
logging.info('Not voting on aborted job %s (%s)',
job, job.result)
job.update(self.db, state=constants.FINISHED)
continue
if Configuration().get_bool('VOTE'):
message = Configuration().VOTE_MESSAGE % {'result':job.result,
'report': job.report_url,
'log':job.logs_url}
vote_num = "+1" if job.result == 'Passed' else "-1"
if ((vote_num == '+1') or (not Configuration().get_bool('VOTE_PASSED_ONLY'))):
logging.info('Posting results for %s (%s)',
job, job.result)
vote(job.commit_id, vote_num, message)
job.update(self.db, state=constants.FINISHED)
示例9: postResults
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def postResults(self):
allJobs = Job.getAllWhere(self.db, state=constants.COLLECTED)
self.log.info("%d jobs ready to be posted..." % len(allJobs))
for job in allJobs:
if job.result.find("Aborted") == 0:
logging.info("Not voting on aborted job %s (%s)", job, job.result)
job.update(self.db, state=constants.FINISHED)
continue
if Configuration().get_bool("VOTE"):
message = Configuration().VOTE_MESSAGE % {
"result": job.result,
"report": job.report_url,
"log": job.logs_url,
}
vote_num = "+1" if job.result == "Passed" else "-1"
if (vote_num == "+1") or (not Configuration().get_bool("VOTE_PASSED_ONLY")):
logging.info("Posting results for %s (%s)", job, job.result)
vote(job.commit_id, vote_num, message)
job.update(self.db, state=constants.FINISHED)
示例10: get_queued_enabled_jobs
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def get_queued_enabled_jobs(self):
allJobs = Job.getAllWhere(self.db, state=constants.QUEUED)
self.log.info('%d jobs queued...'%len(allJobs))
if self.jobs_enabled:
return allJobs
return []
示例11: get_queued_enabled_jobs
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def get_queued_enabled_jobs(self):
allJobs = Job.getAllWhere(self.db, state=constants.QUEUED)
self.log.info("%d jobs queued..." % len(allJobs))
if Configuration().get_bool("RUN_TESTS"):
return allJobs
return []
示例12: recheckJob
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def recheckJob(self, job_id):
allJobs = Job.getAllWhere(self.db, id=job_id)
for job in allJobs:
self.addJob(job.change_ref, job.project_name, job.commit_id)
示例13: triggerJob
# 需要导入模块: from osci.job import Job [as 别名]
# 或者: from osci.job.Job import getAllWhere [as 别名]
def triggerJob(self, job_id):
allJobs = Job.getAllWhere(self.db, id=job_id)
for job in allJobs:
job.runJob(self.db, self.nodepool)