Danke für die Hilfe mit Python.
Jetzt kommt alles richtig. Beide 'ä' werden angezeigt.
Code: Alles auswählen
pi@openWB:/var/www/html/openWB $ python3 ./modules/_senec/Test.py
ääpi@openWB:/var/www/html/openWB $
Code: Alles auswählen
pi@openWB:/var/www/html/openWB $ python3 ./modules/_senec/Test.py
ääpi@openWB:/var/www/html/openWB $
Code: Alles auswählen
pi@openWB:~ $ python -V
Python 2.7.13
pi@openWB:~ $ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import sys
>>>
>>> sys.stdout.write("ä")
ä>>> sys.stdout.write("\xe4")
▒>>>
pi@openWB:~ $ python3 -V
Python 3.5.3
pi@openWB:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>
>>> sys.stdout.write("ä")
ä1
>>> sys.stdout.write("\xe4")
ä1
>>>
Code: Alles auswählen
pi@raspi4:~ $ python -V
Python 2.7.16
pi@raspi4:~ $ python
Python 2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>
>>> sys.stdout.write("ä")
ä>>> sys.stdout.write("\xe4")
▒>>>
pi@raspi4:~ $ python3 -V
Python 3.7.3
pi@raspi4:~ $ python3
Python 3.7.3 (default, Jan 22 2021, 20:04:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>>
>>> sys.stdout.write("ä")
ä1
>>> sys.stdout.write("\xe4")
ä1
>>>
Code: Alles auswählen
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 55: ordinal not in range(128)
Call stack:
File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/var/www/html/openWB/packages/legacy_run_server.py", line 56, in handle_connection
self.__callback(read_all_bytes(connection))
File "/var/www/html/openWB/packages/legacy_run_server.py", line 77, in handle_message
importlib.import_module(parsed[0]).main(parsed[1:])
File "/var/www/html/openWB/packages/modules/json/device.py", line 100, in main
{"bat": read_legacy_bat, "counter": read_legacy_counter, "inverter": read_legacy_inverter}, argv
File "/var/www/html/openWB/packages/helpermodules/cli/_run_using_positional_cli_args.py", line 34, in run_using_positional_cli_args
args.RUN(args)
File "/var/www/html/openWB/packages/helpermodules/cli/_run_using_positional_cli_args.py", line 19, in <lambda>
parser.set_defaults(RUN=lambda args: function(*[getattr(args, argument_name) for argument_name in arg_spec.args]))
File "/var/www/html/openWB/packages/modules/json/device.py", line 90, in read_legacy_counter
jq_exported=jq_exported
File "/var/www/html/openWB/packages/modules/json/device.py", line 77, in read_legacy
dev.update()
File "/var/www/html/openWB/packages/modules/json/device.py", line 60, in update
self._components[component].update(response.json())
File "/var/www/html/openWB/packages/modules/json/counter.py", line 35, in update
log.MainLogger().debug("Komponente "+self.component_config["name"]+" auslesen.")
File "/var/www/html/openWB/packages/helpermodules/log.py", line 40, in debug
self.logger.debug(message, exc_info=exception)
Message: 'Komponente Json Z\xe4hler auslesen.'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "/usr/lib/python3.5/logging/__init__.py", line 983, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 55: ordinal not in range(128)
Call stack:
File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/var/www/html/openWB/packages/legacy_run_server.py", line 56, in handle_connection
self.__callback(read_all_bytes(connection))
File "/var/www/html/openWB/packages/legacy_run_server.py", line 77, in handle_message
importlib.import_module(parsed[0]).main(parsed[1:])
File "/var/www/html/openWB/packages/modules/json/device.py", line 100, in main
{"bat": read_legacy_bat, "counter": read_legacy_counter, "inverter": read_legacy_inverter}, argv
File "/var/www/html/openWB/packages/helpermodules/cli/_run_using_positional_cli_args.py", line 34, in run_using_positional_cli_args
args.RUN(args)
File "/var/www/html/openWB/packages/helpermodules/cli/_run_using_positional_cli_args.py", line 19, in <lambda>
parser.set_defaults(RUN=lambda args: function(*[getattr(args, argument_name) for argument_name in arg_spec.args]))
File "/var/www/html/openWB/packages/modules/json/device.py", line 90, in read_legacy_counter
jq_exported=jq_exported
File "/var/www/html/openWB/packages/modules/json/device.py", line 77, in read_legacy
dev.update()
File "/var/www/html/openWB/packages/modules/json/device.py", line 60, in update
self._components[component].update(response.json())
File "/var/www/html/openWB/packages/modules/json/counter.py", line 35, in update
log.MainLogger().debug("Komponente "+self.component_config["name"]+" auslesen.")
File "/var/www/html/openWB/packages/helpermodules/log.py", line 40, in debug
self.logger.debug(message, exc_info=exception)
Message: 'Komponente Json Z\xe4hler auslesen.'
Arguments: ()
Also du meinst bei meinem Programm kommt alles richtig, ja? Nicht im openWB-Log, oder? Oder hast du jetzt magischerweise im openWB.log "Komponente HTTP Zähler auslesen." drin stehen?
Code: Alles auswählen
python3 -c 'print("ä")' 2>&1 | while read -r line; do echo $line; done
Ich habe die Vermutung, dass es ein Fehler ist, dass der Fehler im Log nicht kommt. So ironisch das auch ist. Das versuche ich in #1935 zu beheben. Wenn der gemergt ist kommt der Fehler vermutlich wieder.
Code: Alles auswählen
pi@openWB:/var/www/html/openWB $ python3 -c 'print("ä")' 2>&1 | while read -r line; do echo $line; done
ä
pi@openWB:/var/www/html/openWB $
Code: Alles auswählen
pi@openWB:/var/www/html/openWB $ locale
LANG=de_DE.UTF-8
LANGUAGE=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=de_DE.UTF-8