本文整理匯總了Python中application.modules.tasks.TaskApi.create_tasks方法的典型用法代碼示例。如果您正苦於以下問題:Python TaskApi.create_tasks方法的具體用法?Python TaskApi.create_tasks怎麽用?Python TaskApi.create_tasks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類application.modules.tasks.TaskApi
的用法示例。
在下文中一共展示了TaskApi.create_tasks方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: reset
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_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: reset
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_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))
示例3: reset
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_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
示例4: post
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_tasks [as 別名]
def post(self):
args = job_parser.parse_args()
"""job_settings = {
'frame_start' : args['frame_start'],
'frame_end' : args['frame_end'],
'chunk_size' : args['chunk_size'],
'filepath' : args['filepath'],
'render_settings' : args['render_settings'],
'format' : args['format'],
}"""
status = 'ready'
if args['start_job'] and args['start_job'] == 'True':
status = 'running'
job = Job(
project_id=args['project_id'],
settings=args['settings'],
name=args['name'],
status=status,
type=args['type'],
priority=args['priority'],
date_edit=datetime.now())
db.session.add(job)
db.session.commit()
serverstorage = app.config['SERVER_STORAGE']
projectpath = join(serverstorage, str(job.project_id))
try:
os.mkdir(projectpath)
except:
pass
# Try to make a folder for the job
jobpath = join(projectpath, str(job.id))
try:
os.mkdir(jobpath)
except:
pass
# If we provided a file with the request, we save it there
if args['jobfile']:
args['jobfile'].save(join(jobpath, 'jobfile_{0}.zip'.format(job.id)))
allowed_managers = args['managers']
for m in allowed_managers:
logging.info("Allowed managers: {0}".format(int(m)))
db.session.add(JobManagers(job_id=job.id, manager_id=int(m)))
db.session.commit()
TaskApi.create_tasks(job)
return job, 201
示例5: post
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_tasks [as 別名]
def post(self):
args = job_parser.parse_args()
"""job_settings = {
'frame_start' : args['frame_start'],
'frame_end' : args['frame_end'],
'chunk_size' : args['chunk_size'],
'filepath' : args['filepath'],
'render_settings' : args['render_settings'],
'format' : args['format'],
}"""
status = "stopped"
if args['start_job']:
status = 'running'
job = Job(
project_id=args['project_id'],
settings=args['settings'],
name=args['name'],
status=status,
type=args['type'],
priority=args['priority'])
db.session.add(job)
db.session.commit()
serverstorage = app.config['SERVER_STORAGE']
projectpath = join(serverstorage, str(job.project_id))
try:
os.mkdir(projectpath)
except:
pass
if args['jobfile']:
jobpath = join(projectpath, str(job.id))
try:
os.mkdir(jobpath)
except:
pass
args['jobfile'].save( join(jobpath, 'jobfile_{0}.zip'.format(job.id)) )
allowed_managers = args['managers']
for m in allowed_managers:
print "allowed managers: %d" % int(m)
db.session.add(JobManagers(job_id=job.id, manager_id=int(m)))
db.session.commit()
TaskApi.create_tasks(job)
return job, 201
示例6: reset
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_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
示例7: reset
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_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
示例8: post
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_tasks [as 別名]
def post(self):
args = job_parser.parse_args()
job = Job(
project_id=args['project_id'],
frame_start=args['frame_start'],
frame_end=args['frame_end'],
chunk_size=args['chunk_size'],
current_frame=args['current_frame'],
filepath=args['filepath'],
name=args['job_name'],
render_settings=args['render_settings'],
format=args['format'],
status=args['status'],
priority=args['priority'])
db.session.add(job)
db.session.commit()
logging.info('Parsing job to create tasks')
TaskApi.create_tasks(job)
logging.info('Refresh list of available workers')
TaskApi.dispatch_tasks(job.id)
return job, 201
示例9: post
# 需要導入模塊: from application.modules.tasks import TaskApi [as 別名]
# 或者: from application.modules.tasks.TaskApi import create_tasks [as 別名]
def post(self):
args = job_parser.parse_args()
"""job_settings = {
# 'frame_start' : args['frame_start'],
# 'frame_end' : args['frame_end'],
'frames': args['frames'],
'chunk_size' : args['chunk_size'],
'filepath' : args['filepath'],
'render_settings' : args['render_settings'],
'format' : args['format'],
}"""
status = 'paused'
if args['start_job'] and args['start_job'] == 'True':
status = 'waiting'
if args['username']:
user_id = None
user = User.query.filter_by(email=args['username']).first()
if user:
user_id = user.id
else:
# TODO move this in a more appropriate location. Right now we
# create the user if missing. This should be done on the auth
# headers level (and hooked up with a real auth system).
user = User(
email=args['username'],
password=''.join(random.choice(
string.ascii_uppercase + string.digits) for _ in range(5)),
active=True,
current_login_at=datetime.now(),
current_login_ip=request.remote_addr,
login_count=1)
db.session.add(user)
db.session.commit()
user_id = user.id
job = Job(
project_id=args['project_id'],
settings=args['settings'],
name=args['name'],
status=status,
type=args['type'],
priority=args['priority'],
date_edit=datetime.now(),
user_id=user_id)
db.session.add(job)
db.session.commit()
serverstorage = app.config['SERVER_STORAGE']
projectpath = join(serverstorage, str(job.project_id))
try:
os.mkdir(projectpath)
except:
pass
# Try to make a folder for the job
jobpath = join(projectpath, str(job.id))
try:
os.mkdir(jobpath)
except:
pass
# If we provided a file with the request, we save it there
if args['jobfile']:
args['jobfile'].save(join(jobpath, 'jobfile_{0}.zip'.format(job.id)))
allowed_managers = args['managers']
for m in allowed_managers:
logging.info("Allowed managers: {0}".format(int(m)))
db.session.add(JobManagers(job_id=job.id, manager_id=int(m)))
db.session.commit()
TaskApi.create_tasks(job)
return job, 201