mirror of
https://github.com/morpheus65535/bazarr
synced 2025-03-03 18:15:50 +00:00
System --> Scheduler fine tuning
This commit is contained in:
parent
5b43af7a4c
commit
09cb87feeb
2 changed files with 78 additions and 3 deletions
79
bazarr.py
79
bazarr.py
|
@ -302,12 +302,87 @@ def system():
|
|||
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
|
||||
logs.append(line.rstrip())
|
||||
|
||||
def get_time_from_interval(interval):
|
||||
interval_clean = interval.split('[')
|
||||
interval_clean = interval_clean[1][:-1]
|
||||
interval_split = interval_clean.split(':')
|
||||
|
||||
text = "every "
|
||||
if interval_split[0] != "0":
|
||||
text = text + interval_split[0]
|
||||
if interval_split[0] == "1":
|
||||
text = text + " hour"
|
||||
else:
|
||||
text = text + " hours"
|
||||
|
||||
if interval_split[2] == "00":
|
||||
text = text + " and "
|
||||
elif interval_split[1] != "00":
|
||||
text = text + ", "
|
||||
if interval_split[1] != "00":
|
||||
text = text + interval_split[1].lstrip("0")
|
||||
if interval_split[1].lstrip("0") == "1":
|
||||
text = text + " minute"
|
||||
else:
|
||||
text = text + " minutes"
|
||||
|
||||
if interval_split[2] != "00":
|
||||
text = text + " and "
|
||||
if interval_split[1] == "00":
|
||||
text = text + " and "
|
||||
if interval_split[2] != "00":
|
||||
text = text + interval_split[2].lstrip("0")
|
||||
if interval_split[2].lstrip("0") == "1":
|
||||
text = text + " second"
|
||||
else:
|
||||
text = text + " seconds"
|
||||
|
||||
return text
|
||||
|
||||
def get_time_from_cron(cron):
|
||||
text = "at "
|
||||
hour = str(cron[5])
|
||||
minute = str(cron[6])
|
||||
second = str(cron[7])
|
||||
|
||||
if hour != "0" and hour != "*":
|
||||
text = text + hour
|
||||
if hour == "0" or hour == "1":
|
||||
text = text + " hour"
|
||||
else:
|
||||
text = text + " hours"
|
||||
|
||||
if minute != "*" and second != "0":
|
||||
text = text + ", "
|
||||
elif minute == "*" and second != "0":
|
||||
text = text + " and "
|
||||
elif minute != "0" and minute != "*" and second == "0":
|
||||
text = text + " and "
|
||||
if minute != "0" and minute != "*":
|
||||
text = text + minute
|
||||
if minute == "0" or minute == "1":
|
||||
text = text + " minute"
|
||||
else:
|
||||
text = text + " minutes"
|
||||
|
||||
if second != "0" and second != "*":
|
||||
text = text + " and "
|
||||
if second != "0" and second != "*":
|
||||
text = text + second
|
||||
if second == "0" or second == "1":
|
||||
text = text + " second"
|
||||
else:
|
||||
text = text + " seconds"
|
||||
|
||||
return text
|
||||
|
||||
|
||||
task_list = []
|
||||
for job in scheduler.get_jobs():
|
||||
if job.trigger.__str__().startswith('interval'):
|
||||
task_list.append([job.name, job.trigger.interval.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
|
||||
task_list.append([job.name, get_time_from_interval(str(job.trigger)), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
|
||||
elif job.trigger.__str__().startswith('cron'):
|
||||
task_list.append([job.name, job.trigger.__str__(), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
|
||||
task_list.append([job.name, get_time_from_cron(job.trigger.fields), pretty.date(job.next_run_time.replace(tzinfo=None)), job.id])
|
||||
|
||||
return template('system', tasks=tasks, logs=logs, base_url=base_url, task_list=task_list, bazarr_version=bazarr_version)
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@
|
|||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Interval</th>
|
||||
<th>Execution Frequency</th>
|
||||
<th>Next Execution</th>
|
||||
<th class="collapsing"></th>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue