raspishake / rsudp

Continuous visual display, sudden motion monitoring, and historical replay of Raspberry Shake data
https://raspishake.github.io/rsudp/
GNU General Public License v3.0
55 stars 32 forks source link

log error when using telegram module #27

Closed Larusrafn closed 2 years ago

Larusrafn commented 2 years ago

on windows environment, when using telegram module to send warnings about triggered event, this error shows:

2021-10-28 00:02:36 [Alert] Trigger threshold of 2.7 exceeded at 2021-10-28 00:02:36.48
2021-10-28 00:02:36 [Alert] Trigger will reset when STA/LTA goes below 2.5...
2021-10-28 00:02:36 [Producer] Alert thread has indicated alarm state, sending ALARM message to queues
2021-10-28 00:02:36 [AlertSound] Playing alert sound...
2021-10-28 00:02:36 [Telegram id -1001674859833] Sending alert...
2021-10-28 00:02:37 [Plot] Event time: 2021-10-28 00:02:36.48 UTC4.6147←[0m←[2Km←[1m
2021-10-28 00:02:37 [Plot] Saving png in about 42 seconds
--- Logging error ---
Traceback (most recent call last):
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\logging\__init__.py", line 1028, in emit
    stream.write(msg + self.terminator)
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 174-175: character maps to <undefined>
Call stack:
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\threading.py", line 890, in _bootstrap
    self._bootstrap_inner()
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\site-packages\rsudp\c_telegram.py", line 150, in run
    self._when_alarm(d)
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\site-packages\rsudp\c_telegram.py", line 95, in _when_alarm
    printM('Sent Telegram: %s' % (message), sender=self.sender)
  File "C:\Users\lalli\miniconda3\envs\rsudp\lib\site-packages\rsudp\__init__.py", line 169, in printM
    LOG.info(msg)
Message: '[Telegram id -1001674859833] Sent Telegram: (Raspberry Shake station AM.R075C - region: Iceland) Event detected at 2021-10-28 00:02:36.48 UTC - live feed ➡️ https://raspberryshake.net/stationview/#?net=AM&sta=R075C'
Arguments: ()
2021-10-28 00:02:37 [Telegram id -1001674859833] Sent Telegram: (Raspberry Shake station AM.R075C - region: Iceland) Event detected at 2021-10-28 00:02:36.48 UTC - live feed ➡️ https://raspberryshake.net/stationview/#?net=AM&sta=R075C
2021-10-28 00:02:41 [Alert] Threshold: 2.7; Current max STA/LTA: 2.5355←[0m←[95m←[1m
2021-10-28 00:02:42 [Alert] Max STA/LTA ratio reached in alarm state: 4.922
2021-10-28 00:02:42 [Alert] Earthquake trigger reset and active again at 2021-10-28 00:02:41.73
2021-10-28 00:02:42 [Producer] Alert thread has indicated alarm reset, sending RESET message to queues
2021-10-28 00:03:18 [Alert] Threshold: 2.7; Current max STA/LTA: 0.1012←[0m←[92m←[1m

sending the message is successful, and the screenshot too. just wanted to report the error.

iannesbitt commented 2 years ago

This is probably just because emoji can't be written to the log file. I will work on finding a way to work around the error. Thanks for the report.

iannesbitt commented 2 years ago

Hi @Larusrafn, this error should no longer happen as of the above commit. I've also bumped the version to 1.0.3. You can go ahead and install from master to test that this particular error no longer happens on Windows in version 1.0.3. I'm going to close the issue but feel free to reopen if the problem is not solved.

Larusrafn commented 2 years ago

verified, the error does not appear running current master (1.0.3), thanks.