Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cron_job_edit(crontab_id=0, cron_id=0):
if request.method == 'POST':
obj = parse_cron_widget(CronTabs()[crontab_id - 1], cron_id)
if obj != None:
return obj
try:
return render_template('cron_job_edit.html', cron=CronTabs()[crontab_id - 1].crons[cron_id - 1])
except:
return redirect(url_for('system.cron_jobs'))
def __new__(cls, *args, **kw):
if not cls._self:
cls._self = super(CronTabs, cls).__new__(cls, *args, **kw)
return cls._self
if request.method == 'POST':
action = request.form['action']
if action == 'delete':
crontab_id = int(request.form['crontab_id'])
cron_id = int(request.form['cron_id'])
crontab = CronTabs()[crontab_id - 1]
job = crontab.crons[cron_id - 1]
crontab.remove(job)
crontab.write()
else:
tabfile = request.form['tabfile']
obj = parse_cron_widget(CronTab(tabfile=tabfile))
if obj != None:
return obj
for crontab in CronTabs():
for cron in crontab:
print(cron)
return render_template('cron_jobs.html', crontabs=CronTabs(), crontab_locations=get_cron_locations())
crontab_id = int(request.form['crontab_id'])
cron_id = int(request.form['cron_id'])
crontab = CronTabs()[crontab_id - 1]
job = crontab.crons[cron_id - 1]
crontab.remove(job)
crontab.write()
else:
tabfile = request.form['tabfile']
obj = parse_cron_widget(CronTab(tabfile=tabfile))
if obj != None:
return obj
for crontab in CronTabs():
for cron in crontab:
print(cron)
return render_template('cron_jobs.html', crontabs=CronTabs(), crontab_locations=get_cron_locations())
def cron_jobs():
if request.method == 'POST':
action = request.form['action']
if action == 'delete':
crontab_id = int(request.form['crontab_id'])
cron_id = int(request.form['cron_id'])
crontab = CronTabs()[crontab_id - 1]
job = crontab.crons[cron_id - 1]
crontab.remove(job)
crontab.write()
else:
tabfile = request.form['tabfile']
obj = parse_cron_widget(CronTab(tabfile=tabfile))
if obj != None:
return obj
for crontab in CronTabs():
for cron in crontab:
print(cron)
return render_template('cron_jobs.html', crontabs=CronTabs(), crontab_locations=get_cron_locations())