job_list = '<h3>Job Info</h3><br/>'
for job in scheduler.get_jobs():
job_list += job.name + job.trigger['hour'] + job.trigger['minute'] + job.statusYou can't concatenate arbitrary types in Python. Use string
formatting instead:
https://docs.python.org/3.5/library/stdtypes.html#printf-style-string-formatting
--
You received this message because you are subscribed to the Google Groups "APScheduler" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apscheduler...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
joblist = ''
for job in scheduler.get_jobs():
job = scheduler.get_job(job.id)
for f in job.trigger.fields:
if f.name == 'hour':
hour = f
if f.name == 'minute':
minute = f
joblist += '%(jobname)s : %(jobhour)s:%(jobminute)s' % {"jobname": job.name, "jobhour": hour, "jobminute": minute}
return joblist With this code, your jobs will be concatenated to one string without any delimiters and it looks bad.
How about this instead?
joblist = []
joblist.append('{job.name}:
{job.hour}:{job.minute}'.format(job=job))
return '\n'.join(joblist)
| from datetime import datetime, timedelta | |
| class Config(object): | |
| JOBS = [ | |
| { | |
| 'id': 'cron_coffee', | |
| 'func': 'jobs:make_coffee', | |
| 'trigger': 'cron', | |
| 'hour': '7', | |
| 'minute': '1', | |
| }, | |
| ] | |
| SCHEDULER_VIEWS_ENABLED = True |
With this code, your jobs will be concatenated to one string without any delimiters and it looks bad.
How about this instead?
joblist = []
joblist.append('{job.name}: {job.hour}:{job.minute}'.format(job=job))
return '\n'.join(joblist)
for job in scheduler.get_jobs():
job = scheduler.get_job(job.id)