today i wanted to write a program which execute a few functions at a given date/time, and i can't figure out how. here is what Iwant to achieve:
I would like to let a python script run for a week, and i want it to do 3 functions every day (at a given time):
- every day at 8:00 print(" good morning")
- every day at 13:00 print (" good evening")
- every day at 19:00 print("good night")
at the end of the week I want it to end the script or shutdown the PI (anything as long as the script stops)
I looked into it all day, but i couldn't find a good solution.
I know i can set the rpi up so it starts a python script at a given time (with crontab), but i don't want that.
I also puzzled a lot with APScheduler, but it throws me a bunch of errors after I start it. (errors below if anyone interested)
Code: Select all
Traceback (most recent call last):
File "start.py", line 64, in <module>
menu()
File "start.py", line 35, in menu
options.run()
File "/home/pi/options.py", line 243, in run
schedulerun()
File "/home/pi/options.py", line 122, in schedulerun
schedule = BackgroundScheduler()
File "/usr/local/lib/python3.2/dist-packages/APScheduler-3.0.1-py3.2.egg/apscheduler/schedulers/base.py", line 61, in __init__
self.configure(gconfig, **options)
File "/usr/local/lib/python3.2/dist-packages/APScheduler-3.0.1-py3.2.egg/apscheduler/schedulers/base.py", line 95, in configure
self._configure(config)
File "/usr/local/lib/python3.2/dist-packages/APScheduler-3.0.1-py3.2.egg/apscheduler/schedulers/background.py", line 27, in _configure
super(BackgroundScheduler, self)._configure(config)
File "/usr/local/lib/python3.2/dist-packages/APScheduler-3.0.1-py3.2.egg/apscheduler/schedulers/base.py", line 576, in _configure
self.timezone = astimezone(config.pop('timezone', None)) or get_localzone()
File "/usr/local/lib/python3.2/dist-packages/tzlocal-1.1.2-py3.2.egg/tzlocal/unix.py", line 108, in get_localzone
File "/usr/local/lib/python3.2/dist-packages/tzlocal-1.1.2-py3.2.egg/tzlocal/unix.py", line 61, in _get_localzone
File "/usr/local/lib/python3.2/dist-packages/pytz-2014.7-py3.2.egg/pytz/__init__.py", line 173, in timezone
File "/usr/local/lib/python3.2/dist-packages/pytz-2014.7-py3.2.egg/pytz/lazy.py", line 150, in _lazy
File "/usr/local/lib/python3.2/dist-packages/pytz-2014.7-py3.2.egg/pytz/lazy.py", line 97, in _lazy
File "/usr/local/lib/python3.2/dist-packages/pytz-2014.7-py3.2.egg/pytz/__init__.py", line 1073, in <genexpr>
File "/usr/local/lib/python3.2/dist-packages/pytz-2014.7-py3.2.egg/pytz/__init__.py", line 102, in resource_exists
File "/usr/local/lib/python3.2/dist-packages/pytz-2014.7-py3.2.egg/pytz/__init__.py", line 95, in open_resource
File "/home/pi/di/pkg_resources.py", line 949, in resource_stream
self, resource_name
File "/home/pi/di/pkg_resources.py", line 1379, in get_resource_stream
return StringIO(self.get_resource_string(manager, resource_name))
File "/home/pi/di/pkg_resources.py", line 1956, in StringIO
return StringIO(*args,**kw)
TypeError: initial_value must be str or None, not bytes
thanks in advance!