Skip to content

Commit

Permalink
Tidy job time display
Browse files Browse the repository at this point in the history
  • Loading branch information
philborman committed Jun 1, 2018
1 parent e8118a9 commit bbb8868
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lazylibrarian/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ def scheduleJob(action='Start', target=None):
if not authcount:
minutes = 60
else:
minutes = int(minutes / authcount)
# Allow a few minutes per task - interval starts from END of previous task
minutes = int(minutes / authcount) - 5

if minutes < 10: # set a minimum interval of 10 minutes so we don't upset goodreads/librarything api
minutes = 10
Expand Down Expand Up @@ -633,7 +634,7 @@ def showJobs():
jobname = job.split(' ')[0].split('.')[2]

# jobinterval = job.split('[')[1].split(']')[0]
jobtime = job.split('at: ')[1].split('.')[0]
jobtime = job.split('at: ')[1].split('.')[0].strip(')')
jobtime = next_run(jobtime)
timeparts = jobtime.split(' ')
if timeparts[0] == '1' and timeparts[1].endswith('s'):
Expand Down
4 changes: 3 additions & 1 deletion lazylibrarian/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ def next_run(when_run):
timenow = datetime.datetime.now()
td = when_run - timenow
diff = td.seconds # time difference in seconds
except ValueError:
except ValueError as e:
logger.error("Error getting next run for [%s] %s" % (when_run, str(e)))
diff = 0

# calculate whole units, plus round up by adding 1(true) if remainder >= half
days = int(diff / 86400) + (diff % 86400 >= 43200)
hours = int(diff / 3600) + (diff % 3600 >= 1800)
Expand Down

0 comments on commit bbb8868

Please sign in to comment.