fix: 清理错误定时策略并支持生成cron文本2
This commit is contained in:
parent
7423d84f81
commit
51acf6caa0
|
@ -2,6 +2,7 @@ import locale
|
||||||
from croniter import croniter
|
from croniter import croniter
|
||||||
from cron_descriptor import get_description
|
from cron_descriptor import get_description
|
||||||
from safesite.models import MySchedule, GridTaskSet, PeriodicTask
|
from safesite.models import MySchedule, GridTaskSet, PeriodicTask
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
period_dict = {
|
period_dict = {
|
||||||
"days": "天",
|
"days": "天",
|
||||||
"hours": "小时",
|
"hours": "小时",
|
||||||
|
@ -33,10 +34,14 @@ def correct_myschedule():
|
||||||
item.name = get_chinese_description(typeset, {'every': interval.every, 'period': interval.period})
|
item.name = get_chinese_description(typeset, {'every': interval.every, 'period': interval.period})
|
||||||
item.save()
|
item.save()
|
||||||
elif typeset == 'crontab':
|
elif typeset == 'crontab':
|
||||||
crontab = item.crontab
|
try:
|
||||||
item.name = get_chinese_description(typeset,
|
crontab = item.crontab
|
||||||
{"minute": crontab.minute, "hour": crontab.hour, "day_of_month": crontab.day_of_month,
|
item.name = get_chinese_description(typeset,
|
||||||
"month_of_year": crontab.month_of_year, "day_of_week": crontab.day_of_week})
|
{"minute": crontab.minute, "hour": crontab.hour, "day_of_month": crontab.day_of_month,
|
||||||
if item.name == '':
|
"month_of_year": crontab.month_of_year, "day_of_week": crontab.day_of_week})
|
||||||
crontab.delete()
|
if item.name == '':
|
||||||
|
crontab.delete()
|
||||||
|
item.delete()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
GridTaskSet.objects.filter(myschedule=item).delete()
|
||||||
item.delete()
|
item.delete()
|
Loading…
Reference in New Issue