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