WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How can I get an apscheduler extension?  (Read 6255 times)

Offline Terry_J_C

  • Newbie
  • *
  • Posts: 22
How can I get an apscheduler extension?
« on: August 20, 2016, 09:25:22 AM »
Hi,

I'm currently developing a Python program to play some sounds at regular intervals throughout the day.  I've done this on my Linux PC using apscheduler, so know how I can do it.  I understand that it can be done in Raspbian, but I don't believe that the apscheduler extension exists for piCore.

I want this system to run totally unattended for weeks and months on end and also be immune to power cuts or accidental shut-downs, so piCore running live is ideal for the job.  Can anyone explain in words of one syllable how this extension can be built and included?  I am a retired systems engineer, so I only have a smattering of software knowledge, therefore a bit of hand-holding would be much appreciated.
Terry

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1089
Re: How can I get an apscheduler extension?
« Reply #1 on: August 20, 2016, 09:38:56 AM »
can you just use cron?

That works out of the box.  just add cron to the command line


Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How can I get an apscheduler extension?
« Reply #2 on: August 20, 2016, 09:47:22 AM »
This package depends on few other packages which must be built too. To build them is easy the same way as on any other Linux system. Creation of TCZ is explained in WiKi.

However, you may review your design whether this package is really needed or not. Probably you can use asyncio module in Python >= 3.4 if looking for a Pythonic solution, or just use Linux cron as advicxed by Paul.

Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Terry_J_C

  • Newbie
  • *
  • Posts: 22
Re: How can I get an apscheduler extension?
« Reply #3 on: August 20, 2016, 10:24:09 AM »
can you just use cron?

That works out of the box.  just add cron to the command line
I could, but I also want to do some other things with GPIO, between the sounds being played.

Python has a wealth of support out there for people who may pick this up in the years to come.  Most of them will be even less skilled in software development than I am.
Terry

Offline Terry_J_C

  • Newbie
  • *
  • Posts: 22
Re: How can I get an apscheduler extension?
« Reply #4 on: August 20, 2016, 10:25:31 AM »
However, you may review your design whether this package is really needed or not. Probably you can use asyncio module in Python >= 3.4 if looking for a Pythonic solution, or just use Linux cron as advicxed by Paul.
I couldn't see an asyncio extension either.
Terry

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11256
Re: How can I get an apscheduler extension?
« Reply #5 on: August 20, 2016, 10:50:37 AM »
Hi Terry_J_C
However, you may review your design whether this package is really needed or not. Probably you can use asyncio module in Python >= 3.4 if looking for a Pythonic solution, or just use Linux cron as advicxed by Paul.
I couldn't see an asyncio extension either.

I think bmarkus might have been referring to one of these:
Code: [Select]
usr/local/lib/python3.5/asyncio/unix_events.py
usr/local/lib/python3.5/asyncio/transports.py
usr/local/lib/python3.5/asyncio/test_utils.py
usr/local/lib/python3.5/asyncio/tasks.py
usr/local/lib/python3.5/asyncio/subprocess.py
usr/local/lib/python3.5/asyncio/streams.py
usr/local/lib/python3.5/asyncio/sslproto.py
usr/local/lib/python3.5/asyncio/selector_events.py
usr/local/lib/python3.5/asyncio/queues.py
usr/local/lib/python3.5/asyncio/protocols.py
usr/local/lib/python3.5/asyncio/proactor_events.py
usr/local/lib/python3.5/asyncio/log.py
usr/local/lib/python3.5/asyncio/locks.py
usr/local/lib/python3.5/asyncio/futures.py
usr/local/lib/python3.5/asyncio/events.py
usr/local/lib/python3.5/asyncio/coroutines.py
usr/local/lib/python3.5/asyncio/constants.py
usr/local/lib/python3.5/asyncio/compat.py
usr/local/lib/python3.5/asyncio/base_subprocess.py
usr/local/lib/python3.5/asyncio/base_events.py
usr/local/lib/python3.5/asyncio/__init__.py
from:
http://tinycorelinux.net/7.x/armv6/tcz/python3.5.tcz.list

Offline Terry_J_C

  • Newbie
  • *
  • Posts: 22
Re: How can I get an apscheduler extension?
« Reply #6 on: August 20, 2016, 11:06:22 AM »
I think bmarkus might have been referring to one of these:
Code: [Select]
usr/local/lib/python3.5/asyncio/unix_events.py
usr/local/lib/python3.5/asyncio/transports.py
....
usr/local/lib/python3.5/asyncio/__init__.py
from:
http://tinycorelinux.net/7.x/armv6/tcz/python3.5.tcz.list
Ahh!  I see.  Ill have to see what can be done with asyncio.

Thanks.
Terry

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How can I get an apscheduler extension?
« Reply #7 on: August 20, 2016, 01:21:04 PM »
asyncio is the most important addition to Pyton's built-in module set. It makes possible to schedule a coroutine execution after a specified delay (which can be 0) or at absolute time. Coroutines can reschedule themselve, so you have a flexible tool to execute Python code in a future. It is built into distributions stating with 3.4 no external modules needed. See

https://docs.python.org/3/library/asyncio.html#module-asyncio
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Terry_J_C

  • Newbie
  • *
  • Posts: 22
Re: How can I get an apscheduler extension?
« Reply #8 on: August 21, 2016, 12:18:00 AM »
asyncio is the most important addition to Pyton's built-in module set. It makes possible to schedule a coroutine execution after a specified delay (which can be 0) or at absolute time. Coroutines can reschedule themselve, so you have a flexible tool to execute Python code in a future. It is built into distributions stating with 3.4 no external modules needed. See

https://docs.python.org/3/library/asyncio.html#module-asyncio
Thanks.  I did discover that page after you mentioned asyncio yesterday.  My problem is, as originally mentioned, I was never a software engineer so my understanding of what the documentation is telling me is somewhat limited by my understanding of the terminology used.  I came out of the Test Industry, so I am fairly comfortable with sequential programming and I can grasp some of the principles of object oriented and threaded programming, but I'm afraid that documentation leaves me a trifle baffled.  To a lesser extent I have the same problem with the Tiny Core documentation which explains how to add an extension to the system.  Last year, for example, I wanted to used the wiringpi2 Python Library, but was unable to build it as an extension so I ended up recoding in C; which turned out to be relatively easy in that case.

With the Raspberry Pi my skills have mainly been used on the system design and the development of the peripheral hardware. The code used has largely been based on modifying bits of existing code that I've been able to find on the Internet.  I've done this quite a few times now with great success, and in this instance I found it extremely easy to build Python code that would do something at specific times, such as on the hour and at certain minutes before and after the hour.  I did try using the sched Python Module, but as others found on various tech sites I found, apscheduler made for a much simpler and more flexible solution.

So the bottom line for me at the moment is either I work out how to build an extension for apscheduler or I stumble across an example of how to do what I want with asyncio.

Thanks for trying to help.
Terry

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How can I get an apscheduler extension?
« Reply #9 on: August 21, 2016, 01:15:33 AM »
You are right, it is not easy to understand asyncio at first and need some time spent with experimenting. But once you understand, you will like it for sure :)

I will check modules you are missing and if no complication add them to repo.

is your code written in 2.7 or 3.x?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Terry_J_C

  • Newbie
  • *
  • Posts: 22
Re: How can I get an apscheduler extension?
« Reply #10 on: August 21, 2016, 01:43:40 AM »
You are right, it is not easy to understand asyncio at first and need some time spent with experimenting. But once you understand, you will like it for sure :)

I won't give up; I just need a glimmer to show up and I'll probably get the idea eventually  ;D

I will check modules you are missing and if no complication add them to repo.

is your code written in 2.7 or 3.x?

I wasn't sure, since I simply modified a grab from the Internet.  However, I suspect that it is currently syntactically compatible with either, since both Idle 2 and Idle 3 don't complain when I 'Check Module'.  However I do get an error when I try to run it in Idle 3, (can't find module apscheduler), so I guess I should say 2.7.  BTW.  That is running my code on my Kubuntu system; I haven't done anything with it on the Pi yet, even in Raspbian.

If you can add the apscheduler module, it would be much appreciated.
« Last Edit: August 21, 2016, 02:14:51 AM by Terry_J_C »
Terry

Offline bill thomson

  • Newbie
  • *
  • Posts: 5
Re: How can I get an apscheduler extension?
« Reply #11 on: September 17, 2016, 07:28:58 PM »
Hello Terry,

To get APscheduler running, first install pip:
wget https://bootstrap.pypa.io/get-pip.py
make it executable: chmod 755 get-pip.py
run it: sudo -H ./get-pip.py (I used Python 2.7.12 - i.e. I couldn't get it to work using MicroPython)

Once pip is installed, install APscheduler: (NB: the app name is case sensitive)
sudo pip install APscheduler

pip list to verify installation/version

Regards,

Bill Thomson
« Last Edit: September 17, 2016, 07:48:17 PM by bill thomson »

Offline bill thomson

  • Newbie
  • *
  • Posts: 5
Re: How can I get an apscheduler extension?
« Reply #12 on: September 17, 2016, 09:13:00 PM »
Terry,

I forgot to mention this in my last post...

Add these two lines to /opt/.filetool

usr/local/bin
usr/local/lib/python2.7/site-packages


Then do a backup.

It's not as clean/quick as an actual extension, but boot time doesn't seem to be affected a great deal.
(backup time is a bit longer, though)
« Last Edit: September 17, 2016, 09:21:26 PM by bill thomson »

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11256
Re: How can I get an apscheduler extension?
« Reply #13 on: September 17, 2016, 09:33:53 PM »
Hi bill thomson
Quote
Add these two lines to /opt/.filetool
Actually it's  /opt/.filetool.lst

Quote
usr/local/bin
No, do not backup  usr/local/bin. Only backup the files you need, not the entire subdirectory.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: How can I get an apscheduler extension?
« Reply #14 on: September 17, 2016, 09:37:42 PM »
Hi bill thomson
Quote
Add these two lines to /opt/.filetool
Actually it's  /opt/.filetool.lst

Quote
usr/local/bin
No, do not backup  usr/local/bin. Only backup the files you need, not the entire subdirectory.

Nor the site-packages, it may contain other packages from tcz's.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."