On Saturday, 7 January 2017 15:19:05 GMT Ralph Corderoy wrote:
> Bits of Python you might find useful...

.........................

OK.  Thanks.  I'll look into those points.

> > Unfortunately, since then, apscheduler has been updated

In fact, as I've just discovered, it has been updated in Kubuntu, but not in 
Raspbian Jessie, so I could go with that, especially since I'm considering 
running Raspbian Read-only instead of running piCore which continues to make 
things difficult.  There is a new page which was written a few months ago which 
gives chapter and verse:

https://www.raspberrypi.org/forums/viewtopic.php?p=1044815

> You might be able to fix apscheduler at a particular version somehow to
> stop it breaking.

Well once it's working, we won't be updating anything, so it will be fixed (at 
least until someone tries to develop the code further).

> > I think that BackgroundScheduler looks the most likely candidate to do
> > what I want.
> 
> Don't think so.  You existing program did `sched.daemonic = False'
> whereas the default is True for BackgroundScheduler.  Since your program

Well.  I never realised that is what it did.  I grabbed fragments of code off 
the internet and it just worked. 

> wants to do nothing else once it's configured the scheduler other than
> wait for jobs to be triggered, don't you want a plain old
> BlockingScheduler: "A scheduler that runs in the foreground (start()
> will block)".

In fact I want to run the MP3 Player inside the same program if possible.

> > Can anyone help me to get the right syntax to replicate the old
> > functionality
> 
> I've only had a quick look.  The scheduler now needs importing from its
> particular package.
> 
>     < from apscheduler.scheduler import Scheduler
> 
>     > from apscheduler.schedulers.blocking import BlockingScheduler
>
> Instantiating it is different.
> 
>     < sched = Scheduler()
>     < sched.daemonic = False
> 
>     > sched = BlockingScheduler()

I got that far (except that I was using BackgroundScheduler).  It was the 
syntax of the add_job that threw me.  I've been playing around and now have:

sched.add_job(hours, 'cron', hour='10')

etc.  I'm currently waiting for the next event to happen.

> And you move the `sched.start()' to the end of the program, after you've
> added all the jobs rather that just after the instantiation as it is
> now.

Thanks.

-- 



                Terry Coles

-- 
Next meeting:  Bournemouth, Tuesday, 2017-02-07 20:00
Meets, Mailing list, IRC, LinkedIn, ...  http://dorset.lug.org.uk/
New thread:  mailto:dorset@mailman.lug.org.uk / CHECK IF YOU'RE REPLYING
Reporting bugs well:  http://goo.gl/4Xue     / TO THE LIST OR THE AUTHOR

Reply via email to