nlef / moonraker-telegram-bot

Telegram bot to interact with Moonraker (Klipper Web API Server)
Creative Commons Zero v1.0 Universal
245 stars 64 forks source link

Telegram bot does not start when changing time zone #305

Closed MrDavidFantasy closed 6 months ago

MrDavidFantasy commented 6 months ago

What happened and in what context?

I changed the time zone to +2 hours, and the bot stopped launching. After activation debug, in the journal the following error could be observed. ValueError: Timezone offset does not match system offset: 0 != 7200. Please, check your config files. Deleting the bot, changing the time zone, and a new installation did not help. Disabling automatic time synchronization and manually changing the time works. But I want everything to work as it should.

If needed, paste the relevant bot log contents here.

telegram.log The log disappeared after deletion, and did not appear after re-installation. Therefore, I am attaching only the current log, there will probably be no errors in it.

If needed, paste the relevant bot journal contents here.

Mar 01 11:54:50 raspberrypi python[2428]: super(BackgroundScheduler, self)._configure(config) Mar 01 11:54:50 raspberrypi python[2428]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 697, in _configure Mar 01 11:54:50 raspberrypi python[2428]: self.timezone = astimezone(config.pop('timezone', None)) or get_localzone() Mar 01 11:54:50 raspberrypi python[2428]: ^^^^^^^^^^^^^^^ Mar 01 11:54:50 raspberrypi python[2428]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/unix.py", line 165, in get_localzone Mar 01 11:54:50 raspberrypi python[2428]: _cache_tz = _get_localzone() Mar 01 11:54:50 raspberrypi python[2428]: ^^^^^^^^^^^^^^^^ Mar 01 11:54:50 raspberrypi python[2428]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/unix.py", line 90, in _get_localzone Mar 01 11:54:50 raspberrypi python[2428]: utils.assert_tz_offset(tz) Mar 01 11:54:09 raspberrypi systemd[1]: Started moonraker-telegram-bot.service - Moonraker Telegram Bot SV1. Mar 01 11:54:36 raspberrypi python[2179]: 2024-03-01 11:54:36,171 - main - ERROR - Uncaught exception Mar 01 11:54:36 raspberrypi python[2179]: Traceback (most recent call last): Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot/bot/main.py", line 92, in Mar 01 11:54:36 raspberrypi python[2179]: scheduler = BackgroundScheduler( Mar 01 11:54:36 raspberrypi python[2179]: ^^^^^^^^^^^^^^^^^^^^ Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 87, in init Mar 01 11:54:36 raspberrypi python[2179]: self.configure(gconfig, options) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 126, in configure Mar 01 11:54:36 raspberrypi python[2179]: self._configure(config) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/background.py", line 29, in _configure Mar 01 11:54:36 raspberrypi python[2179]: super(BackgroundScheduler, self)._configure(config) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 697, in _configure Mar 01 11:54:36 raspberrypi python[2179]: self.timezone = astimezone(config.pop('timezone', None)) or get_localzone() Mar 01 11:54:36 raspberrypi python[2179]: ^^^^^^^^^^^^^^^ Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/unix.py", line 165, in get_localzone Mar 01 11:54:36 raspberrypi python[2179]: _cache_tz = _get_localzone() Mar 01 11:54:36 raspberrypi python[2179]: ^^^^^^^^^^^^^^^^ Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/unix.py", line 90, in _get_localzone Mar 01 11:54:36 raspberrypi python[2179]: utils.assert_tz_offset(tz) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/utils.py", line 46, in assert_tz_offset Mar 01 11:54:36 raspberrypi python[2179]: raise ValueError(msg) Mar 01 11:54:36 raspberrypi python[2179]: ValueError: Timezone offset does not match system offset: 0 != 7200. Please, check your config files. Mar 01 11:54:09 raspberrypi systemd[1]: Started moonraker-telegram-bot.service - Moonraker Telegram Bot SV1. Mar 01 11:54:36 raspberrypi python[2179]: 2024-03-01 11:54:36,171 - main - ERROR - Uncaught exception Mar 01 11:54:36 raspberrypi python[2179]: Traceback (most recent call last): Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot/bot/main.py", line 92, in Mar 01 11:54:36 raspberrypi python[2179]: scheduler = BackgroundScheduler( Mar 01 11:54:36 raspberrypi python[2179]: ^^^^^^^^^^^^^^^^^^^^ Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 87, in init Mar 01 11:54:36 raspberrypi python[2179]: self.configure(gconfig, options) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 126, in configure Mar 01 11:54:36 raspberrypi python[2179]: self._configure(config) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/background.py", line 29, in _configure Mar 01 11:54:36 raspberrypi python[2179]: super(BackgroundScheduler, self)._configure(config) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/apscheduler/schedulers/base.py", line 697, in _configure Mar 01 11:54:36 raspberrypi python[2179]: self.timezone = astimezone(config.pop('timezone', None)) or get_localzone() Mar 01 11:54:36 raspberrypi python[2179]: ^^^^^^^^^^^^^^^ Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/unix.py", line 165, in get_localzone Mar 01 11:54:36 raspberrypi python[2179]: _cache_tz = _get_localzone() Mar 01 11:54:36 raspberrypi python[2179]: ^^^^^^^^^^^^^^^^ Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/unix.py", line 90, in _get_localzone Mar 01 11:54:36 raspberrypi python[2179]: utils.assert_tz_offset(tz) Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot-env/lib/python3.11/site-packages/tzlocal/utils.py", line 46, in assert_tz_offset Mar 01 11:54:36 raspberrypi python[2179]: raise ValueError(msg) Mar 01 11:54:36 raspberrypi python[2179]: ValueError: Timezone offset does not match system offset: 0 != 7200. Please, check your config files. Mar 01 11:54:36 raspberrypi python[2179]: Stack (most recent call last): Mar 01 11:54:36 raspberrypi python[2179]: File "/home/fantasy/moonraker-telegram-bot/bot/main.py", line 64, in handle_exception Mar 01 11:54:36 raspberrypi python[2179]: logger.error( Mar 01 11:54:36 raspberrypi systemd[1]: moonraker-telegram-bot.service: Main process exited, code=exited, status=1/FAILURE Mar 01 11:54:36 raspberrypi systemd[1]: moonraker-telegram-bot.service: Failed with result 'exit-code'. Mar 01 11:54:36 raspberrypi systemd[1]: moonraker-telegram-bot.service: Consumed 4.790s CPU time. Mar 01 11:54:46 raspberrypi systemd[1]: moonraker-telegram-bot.service: Scheduled restart job, restart counter is at 1. Mar 01 11:54:46 raspberrypi systemd[1]: Stopped moonraker-telegram-bot.service - Moonraker Telegram Bot SV1. Mar 01 11:54:46 raspberrypi systemd[1]: moonraker-telegram-bot.service: Consumed 4.790s CPU time.

What branch does this occur on?

development

Reports only on latest master or development branches!

nlef commented 6 months ago

@MrDavidFantasy It seems that the problem is not in the bot code, but in the environment or system settings try this sudo dpkg-reconfigure tzdata

MrDavidFantasy commented 6 months ago

Thanks, it works.

MrDavidFantasy commented 6 months ago

I changed the time zone as recommended and everything worked.