Erster Stand der Hintergrundprozesse, die auf der Synology unter /volume1/homes/wagner/SolarManager laufen: der Manager selbst, die Sammler je Geraet, die MQTT-Bruecke, der Wecker und - neu hinzugezogen - der AutoAction-Runner, der als Hintergrundprozess hierher gehoert und nicht ins Web-Verzeichnis. Zugangsdaten stehen nicht mehr im Quelltext, sondern in config.ini, die nicht mit eingecheckt wird. Vorlage ist config.ini.example, gelesen wird sie von konfig.py. Betroffen waren solarManager.py (Datenbank und Wattpilot), zeit.py, gatherWaterData.py, wecker.py und skoda_testdaten.py, das sich das Passwort bisher aus dem Quelltext eines anderen Moduls herausgesucht hat. Die Kia-Anbindung ist mit dem Fahrzeug entfallen: kiaTest.py, gatherCarData.py und hyundai_kia_connect_api sind nicht mehr dabei, ebenso gatherInverterData.py, auf das nur noch eine auskommentierte Zeile zeigte. Die mitgelieferten Bibliotheken bleiben im Repository - die NAS hat kein pip, sie muessen neben den Skripten liegen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
#! python
|
|
#
|
|
# This module implements a special URL handler that allows selecting an
|
|
# alternate implementation provided by some backends.
|
|
#
|
|
# This file is part of pySerial. https://github.com/pyserial/pyserial
|
|
# (C) 2015 Chris Liechti <cliechti@gmx.net>
|
|
#
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
#
|
|
# URL format: alt://port[?option[=value][&option[=value]]]
|
|
# options:
|
|
# - class=X used class named X instead of Serial
|
|
#
|
|
# example:
|
|
# use poll based implementation on Posix (Linux):
|
|
# python -m serial.tools.miniterm alt:///dev/ttyUSB0?class=PosixPollSerial
|
|
|
|
from __future__ import absolute_import
|
|
|
|
try:
|
|
import urlparse
|
|
except ImportError:
|
|
import urllib.parse as urlparse
|
|
|
|
import serial
|
|
|
|
|
|
def serial_class_for_url(url):
|
|
"""extract host and port from an URL string"""
|
|
parts = urlparse.urlsplit(url)
|
|
if parts.scheme != 'alt':
|
|
raise serial.SerialException(
|
|
'expected a string in the form "alt://port[?option[=value][&option[=value]]]": '
|
|
'not starting with alt:// ({!r})'.format(parts.scheme))
|
|
class_name = 'Serial'
|
|
try:
|
|
for option, values in urlparse.parse_qs(parts.query, True).items():
|
|
if option == 'class':
|
|
class_name = values[0]
|
|
else:
|
|
raise ValueError('unknown option: {!r}'.format(option))
|
|
except ValueError as e:
|
|
raise serial.SerialException(
|
|
'expected a string in the form '
|
|
'"alt://port[?option[=value][&option[=value]]]": {!r}'.format(e))
|
|
if not hasattr(serial, class_name):
|
|
raise ValueError('unknown class: {!r}'.format(class_name))
|
|
cls = getattr(serial, class_name)
|
|
if not issubclass(cls, serial.Serial):
|
|
raise ValueError('class {!r} is not an instance of Serial'.format(class_name))
|
|
return (''.join([parts.netloc, parts.path]), cls)
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
if __name__ == '__main__':
|
|
s = serial.serial_for_url('alt:///dev/ttyS0?class=PosixPollSerial')
|
|
print(s)
|