Clon1998 / mobileraker_companion

Companion for mobileraker, enabling push notification.
MIT License
209 stars 12 forks source link

Service Traceback when using config file without timezone setting #19

Closed daschu117 closed 1 year ago

daschu117 commented 1 year ago

If I don't include a timezone setting in my mobileraker.conf, then the service crashes continuously that the PST timezone is unknown when my /etc/timezone file contains America/Los_Angeles.

$ cat mobileraker.conf 
[general]
eta_format: %%Y-%%m-%%d, %%H:%%M:%%S
systemd[1]: mobileraker.service: Failed with result 'exit-code'.
systemd[1]: mobileraker.service: Service RestartSec=10s expired, scheduling restart.
systemd[1]: mobileraker.service: Scheduled restart job, restart counter is at 1010.
systemd[1]: Stopped Companion app to enable push notifications on mobileraker.
systemd[1]: Started Companion app to enable push notifications on mobileraker.
python[9023]: 2023-02-26 21:18:54 voron-v0.bufla.net root[9023] INFO Passed config file is: /home/pi/Mobileraker.conf
python[9023]: 2023-02-26 21:18:54 voron-v0.bufla.net root[9023] INFO Found configuration file at: /home/pi/klipper_config/mobileraker.conf
python[9023]: 2023-02-26 21:18:54 voron-v0.bufla.net root[9023] INFO Read 1 printer config sections
python[9023]: Traceback (most recent call last):
python[9023]:   File "/home/pi/mobileraker_companion/mobileraker.py", line 497, in <module>
python[9023]:     main()
python[9023]:   File "/home/pi/mobileraker_companion/mobileraker.py", line 464, in main
python[9023]:     local_config = CompanionLocalConfig(configfile)
python[9023]:   File "/home/pi/mobileraker_companion/configs.py", line 54, in __init__
python[9023]:     self.timezone: datetime.tzinfo = pytz.timezone(self.timezone_str)
python[9023]:   File "/home/pi/mobileraker-env/lib/python3.7/site-packages/pytz/__init__.py", line 188, in timezone
python[9023]:     raise UnknownTimeZoneError(zone)
python[9023]: pytz.exceptions.UnknownTimeZoneError: 'PST'
systemd[1]: mobileraker.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: mobileraker.service: Failed with result 'exit-code'.
$ cat /etc/timezone 
America/Los_Angeles

Works as expected once I define the timezone in mobileraker.conf.

$ cat mobileraker.conf 
[general]
timezone=America/Los_Angeles
eta_format: %%Y-%%m-%%d, %%H:%%M:%%S

Running mobileraker_companion version v0.2.1-41-ge5fa7c8

Clon1998 commented 1 year ago

Please let me know if the latest version resolved this issue!