OK. So now my code runs, but it isn't very efficient. Currently I have one of
these for every hour and every quarter throughout the day:
def one_oclock():
print("One O'clock")
print(datetime.datetime.now())
time.sleep(120)
os.system('mpg321 -g 20 -q ./mp3/Wedding_March.mp3')
time.sleep(300)
os.system('mpg321 -g 100 -q ./mp3/amersham.mp3')
The reason is that I couldn't work out how to pass arguments in the call in
the list of scheduled functions to be run:
sched.add_cron_job(one_oclock, hour='1')
I think I'll still need an entry in the schedule for each event, but I feel I
ought to be able to create a single function for hours and another for
quarters and get the calling cron_job to pass the hour or minute into it. I
tried:
sched.add_cron_job(hours(1), hour='1')
with the function redefined as:
def hours(hour):
print(hour + "O'clock")
Unfortunately, when I tried it I got run-time errors because of argument
mismatches (I tried (1) and ('One'). I couldn't see an example in my Python
book, so kind of ran out of ideas.
Does anyone know what will work?
--
Terry Coles
--
Next meeting: Bournemouth, Tuesday, 2016-09-06 20:00
Meets, Mailing list, IRC, LinkedIn, ... http://dorset.lug.org.uk/
New thread: mailto:[email protected] / CHECK IF YOU'RE REPLYING
Reporting bugs well: http://goo.gl/4Xue / TO THE LIST OR THE AUTHOR