def switch(job_id): job = Job.query.get_or_404(job_id) if request.method == 'POST': job.update(enabled=True) scheduler.add_job(job) elif request.method == 'DELETE': job.update(enabled=False) scheduler.remove_job(job.id) else: abort(405) return json_response()
def switch(job_id): job = Job.query.get_or_404(job_id) if request.method == 'POST': if job.trigger is None: return json_response(message='请在 更多-设置触发器 中配置调度策略') job.update(enabled=True) scheduler.add_job(job) elif request.method == 'DELETE': job.update(enabled=False) scheduler.remove_job(job.id) else: abort(405) return json_response()
def switch(job_id): job = Job.query.get_or_404(job_id) if request.method == 'POST': if job.trigger is None: return json_response(message='请在 更多-设置触发器 中配置调度策略') job.update(enabled=True) command_trans = 'su -l ' + job.command_user + ' -c \'' + job.command + '\'' print("===========", command_trans) if job.command_user == 'root': return json_response({'message': '静止使用root账户提交'}) else: scheduler.add_job(job) elif request.method == 'DELETE': job.update(enabled=False) scheduler.remove_job(job.id) else: abort(405) return json_response()
def delete(job_id): job = Job.query.get_or_404(job_id) job.delete() scheduler.remove_job(job.id) return json_response()