本文整理汇总了Python中application.modules.tasks.TaskApi.delete_tasks方法的典型用法代码示例。如果您正苦于以下问题:Python TaskApi.delete_tasks方法的具体用法?Python TaskApi.delete_tasks怎么用?Python TaskApi.delete_tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application.modules.tasks.TaskApi
的用法示例。
在下文中一共展示了TaskApi.delete_tasks方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def reset(job_id):
job = Job.query.get(job_id)
if job:
if job.status in ['active', 'waiting']:
logging.error("Job {0} is running".format(job_id))
response = jsonify({
'code' : 400,
'message': "This job is running, stop it first."})
response.status_code = 400
return response
else:
log = "Status changed from {0} to {1}".format(job.status, 'waiting')
job.status = 'waiting'
job.tasks_status = json.dumps({
'count': job.tasks.count(),
'completed': 0,
'failed': 0,
'canceled': 0})
job.date_edit = datetime.now()
db.session.commit()
log_to_database(job_id, 'job', log)
TaskApi.delete_tasks(job.id)
TaskApi.create_tasks(job)
logging.info('Job {0} reset end ready'.format(job_id))
else:
logging.error("Job {0} not found".format(job_id))
raise KeyError
示例2: post
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def post(self):
args = id_list.parse_args()
print Job.query.all()
print args['id']
int_list = list_integers_string(args['id'])
for j in int_list:
TaskApi.delete_tasks(j)
job = Job.query.get(j)
if job:
#path = os.path.join(job.project.render_path_server, str(j))
#Security check
#insecure_names=[None, "", "/", "\\", ".", ".."]
#if job.project.render_path_server not in insecure_names and str(j) not in insecure_names:
# if exists(path):
# rmtree(path)
db.session.query(JobManagers).filter(JobManagers.job_id == job.id).delete()
db.session.delete(job)
db.session.commit()
print "[info] Deleted job %d" % j
else:
print "[error] Job %d not found" % j
return '', 404
return '', 204
示例3: reset
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def reset(job_id):
job = Job.query.get(job_id)
if job.status == 'running':
logging.error('Job {0} is running'.format(job_id))
response = jsonify({
'code' : 400,
'message': 'This job is running, stop it first.'})
response.status_code = 400
return response
else:
job.current_frame = job.frame_start
job.status = 'ready'
db.session.add(job)
db.session.commit()
TaskApi.delete_tasks(job.id)
TaskApi.create_tasks(job)
#Security check
insecure_names=[None, "", "/", "\\", ".", ".."]
path = os.path.join(job.project.render_path_server, str(job.id))
if job.project.render_path_server not in insecure_names and str(job.id) not in insecure_names:
if os.path.exists(path):
rmtree(path)
logging.info('Job {0} reset end ready'.format(job_id))
示例4: reset
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def reset(job_id):
job = Job.query.get(job_id)
if job:
if job.status == 'running':
logging.error("Job {0} is running".format(job_id))
response = jsonify({
'code' : 400,
'message': "This job is running, stop it first."})
response.status_code = 400
return response
else:
log = "Status changed from {0} to {1}".format(job.status, 'ready')
job.status = 'ready'
job.date_edit = datetime.now()
db.session.commit()
log_to_database(job_id, 'job', log)
TaskApi.delete_tasks(job.id)
TaskApi.create_tasks(job)
# Security check
# insecure_names = [None, "", "/", "\\", ".", ".."]
# path = join(job.project.render_path_server, str(job.id))
# if job.project.render_path_server not in insecure_names and str(job.id) not in insecure_names:
# if exists(path):
# rmtree(path)
logging.info('Job {0} reset end ready'.format(job_id))
else:
logging.error("Job {0} not found".format(job_id))
raise KeyError
示例5: post
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def post(self):
args = id_list.parse_args()
int_list = list_integers_string(args['id'])
for j in int_list:
TaskApi.delete_tasks(j)
job = Job.query.get(j)
if job:
db.session.query(JobManagers)\
.filter(JobManagers.job_id == job.id).delete()
db.session.delete(job)
db.session.commit()
logging.info("Deleted job {0}".format(j))
else:
logging.error("Job {0} not found".format(j))
return '', 404
return '', 204
示例6: post
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def post(self):
args = id_list.parse_args()
print Job.query.all()
print args['id']
int_list = list_integers_string(args['id'])
for j in int_list:
TaskApi.delete_tasks(j)
job = Job.query.get(j)
if job:
path = os.path.join(job.project.render_path_server, str(j))
if exists(path):
rmtree(path)
db.session.delete(job)
db.session.commit()
print "[info] Deleted job %d" % j
else:
print "[error] Job %d not found" % j
return '', 404
return '', 204
示例7: reset
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def reset(self, job_id):
job = Job.query.get(job_id)
if job:
if job.status == 'running':
print'Job %d is running' % job_id
raise KeyError
else:
job.current_frame = job.frame_start
job.status = 'ready'
db.session.add(job)
db.session.commit()
TaskApi.delete_tasks(job.id)
TaskApi.create_tasks(job)
path = os.path.join(job.project.render_path_server, str(job.id))
if os.path.exists(path):
rmtree(path)
else:
print('[error] Job %d not found' % job_id)
raise KeyError
示例8: reset
# 需要导入模块: from application.modules.tasks import TaskApi [as 别名]
# 或者: from application.modules.tasks.TaskApi import delete_tasks [as 别名]
def reset(self, job_id):
job = Job.query.get(job_id)
if job:
if job.status == 'running':
logging.error("Job {0} is_running".format(job_id))
raise KeyError
else:
job.status = 'ready'
db.session.add(job)
db.session.commit()
TaskApi.delete_tasks(job.id)
TaskApi.create_tasks(job)
path = join(
job.project.render_path_server, str(job.id))
if exists(path):
rmtree(path)
else:
logging.error("Job {0} not found".format(job_id))
raise KeyError