From c45df70e82bf87cd735062b76ca23309327d25ab Mon Sep 17 00:00:00 2001 From: Cedric Hombourger Date: Tue, 7 Jan 2025 17:22:07 +0100 Subject: [PATCH] rfc: replace zerorpc with pyro4 pyro4 is almost a dropin replacement for zerorpc (at least from a usage perspective). Further testing (fixing) is needed before we move forward. Signed-off-by: Cedric Hombourger --- .reuse/dep5 | 8 -- debian/control | 2 +- debian/py3dist-overrides | 1 - meta-isar/recipes-python/mtda/mtda_git.bb | 2 +- ...t_zmq-import-enums-from-pyzmq-23.0.0.patch | 41 ---------- .../files/0002-do-not-use-future.patch | 75 ------------------- .../files/zerorpc-0.6.3/debian/changelog | 35 --------- .../zerorpc/files/zerorpc-0.6.3/debian/compat | 1 - .../files/zerorpc-0.6.3/debian/control | 21 ------ .../files/zerorpc-0.6.3/debian/copyright | 32 -------- .../zerorpc/files/zerorpc-0.6.3/debian/rules | 5 -- .../files/zerorpc-0.6.3/debian/source/format | 1 - .../zerorpc-0.6.3/debian/source/local-options | 2 - .../zerorpc/files/zerorpc-0.6.3/debian/watch | 2 - .../zerorpc/zerorpc-python_0.6.3.bb | 19 ----- mtda-cli | 9 +-- mtda-service | 10 +-- mtda/client.py | 11 ++- mtda/constants.py | 1 - mtda/main.py | 53 +++++++++++++ setup.py | 2 +- 21 files changed, 67 insertions(+), 266 deletions(-) delete mode 100644 meta-isar/recipes-python/zerorpc/files/0001-gevent_zmq-import-enums-from-pyzmq-23.0.0.patch delete mode 100644 meta-isar/recipes-python/zerorpc/files/0002-do-not-use-future.patch delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/changelog delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/compat delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/control delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/copyright delete mode 100755 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/rules delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/format delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/local-options delete mode 100644 meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/watch delete mode 100644 meta-isar/recipes-python/zerorpc/zerorpc-python_0.6.3.bb diff --git a/.reuse/dep5 b/.reuse/dep5 index d9b9462c..c4003493 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -91,14 +91,6 @@ Files: meta-isar/recipes-python/qt5/files/py3qterm-0.4/debian/* Copyright: 2025 Siemens AG License: MIT -Files: meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/* -Copyright: 2025 Siemens AG -License: MIT - -Files: meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/* -Copyright: 2025 Siemens AG -License: MIT - Files: meta-isar/recipes-bsp/rpi-firmware/files/* Copyright: 2025 Siemens AG License: MIT diff --git a/debian/control b/debian/control index c3eb6bfb..0f9e431e 100644 --- a/debian/control +++ b/debian/control @@ -69,7 +69,7 @@ Package: mtda-common Architecture: all Multi-Arch: foreign Depends: python3:any (>= 3.7~), - python3-zerorpc + python3-pyro4 Description: common modules for Multi-Tenant Device Access Modules shared between the service and the client. diff --git a/debian/py3dist-overrides b/debian/py3dist-overrides index ecb6282e..2ba75491 100644 --- a/debian/py3dist-overrides +++ b/debian/py3dist-overrides @@ -1,4 +1,3 @@ kconfiglib python3-kconfiglib requests python3-requests -zerorpc python3-zerorpc zstandard python3-zstandard diff --git a/meta-isar/recipes-python/mtda/mtda_git.bb b/meta-isar/recipes-python/mtda/mtda_git.bb index c9f39bbb..08d57311 100644 --- a/meta-isar/recipes-python/mtda/mtda_git.bb +++ b/meta-isar/recipes-python/mtda/mtda_git.bb @@ -35,7 +35,7 @@ SRC_URI += "${@' '.join(['file://' + d.getVar('LAYERDIR_mtda') + '/../' + file f S = "${WORKDIR}/working-repo" -DEPENDS += "zerorpc-python py3qterm" +DEPENDS += "py3qterm" do_gen_working_repo() { for file in ${MTDA_FILES}; do diff --git a/meta-isar/recipes-python/zerorpc/files/0001-gevent_zmq-import-enums-from-pyzmq-23.0.0.patch b/meta-isar/recipes-python/zerorpc/files/0001-gevent_zmq-import-enums-from-pyzmq-23.0.0.patch deleted file mode 100644 index e56b32e9..00000000 --- a/meta-isar/recipes-python/zerorpc/files/0001-gevent_zmq-import-enums-from-pyzmq-23.0.0.patch +++ /dev/null @@ -1,41 +0,0 @@ -License and copyright for files modified by this patch: - -SPDX-License-Identifier: MIT -Copyright (c) 2015 François-Xavier Bourlet (bombela+zerorpc@gmail.com) - -From dd6843c114e9bfd6e81abf68f6a2eb3c598d1c2f Mon Sep 17 00:00:00 2001 -From: Cedric Hombourger -Date: Thu, 19 May 2022 22:54:27 +0200 -Subject: [PATCH] gevent_zmq: import enums from pyzmq >= 23.0.0 - -With pyzmq 23.0.0, constants were changed to enums and moved to the -constants module. Attempt to import all globals from it into our zmq -wrapper. - -Closes: #251 -Signed-off-by: Cedric Hombourger ---- - zerorpc/gevent_zmq.py | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/zerorpc/gevent_zmq.py b/zerorpc/gevent_zmq.py -index 9430695..54420ae 100644 ---- a/zerorpc/gevent_zmq.py -+++ b/zerorpc/gevent_zmq.py -@@ -27,6 +27,13 @@ - # We want to act like zmq - from zmq import * # noqa - -+try: -+ # Try to import enums for pyzmq >= 23.0.0 -+ from zmq.constants import * # noqa -+except ImportError: -+ pass -+ -+ - # Explicit import to please flake8 - from zmq import ZMQError - --- -2.30.2 - diff --git a/meta-isar/recipes-python/zerorpc/files/0002-do-not-use-future.patch b/meta-isar/recipes-python/zerorpc/files/0002-do-not-use-future.patch deleted file mode 100644 index 3533412a..00000000 --- a/meta-isar/recipes-python/zerorpc/files/0002-do-not-use-future.patch +++ /dev/null @@ -1,75 +0,0 @@ -License and copyright for files modified by this patch: - -SPDX-License-Identifier: MIT -Copyright (c) 2015 François-Xavier Bourlet (bombela+zerorpc@gmail.com) - -Index: zerorpc-0.6.3/zerorpc/context.py -=================================================================== ---- zerorpc-0.6.3.orig/zerorpc/context.py -+++ zerorpc-0.6.3/zerorpc/context.py -@@ -23,9 +23,6 @@ - # SOFTWARE. - - --from __future__ import absolute_import --from future.utils import tobytes -- - import uuid - import random - -@@ -103,7 +100,7 @@ class Context(zmq.Context): - return Context._instance - - def _reset_msgid(self): -- self._msg_id_base = tobytes(uuid.uuid4().hex)[8:] -+ self._msg_id_base = uuid.uuid4().hex[8:].encode('ascii') - self._msg_id_counter = random.randrange(0, 2 ** 32) - self._msg_id_counter_stop = random.randrange(self._msg_id_counter, 2 ** 32) - -@@ -112,7 +109,7 @@ class Context(zmq.Context): - self._reset_msgid() - else: - self._msg_id_counter = (self._msg_id_counter + 1) -- return tobytes('{0:08x}'.format(self._msg_id_counter)) + self._msg_id_base -+ return f'{self._msg_id_counter:08x}'.encode('ascii') + self._msg_id_base - - def register_middleware(self, middleware_instance): - registered_count = 0 -Index: zerorpc-0.6.3/zerorpc/core.py -=================================================================== ---- zerorpc-0.6.3.orig/zerorpc/core.py -+++ zerorpc-0.6.3/zerorpc/core.py -@@ -23,10 +23,8 @@ - # SOFTWARE. - - --from __future__ import absolute_import - from builtins import str - from builtins import zip --from future.utils import iteritems - - import sys - import traceback -@@ -67,7 +65,7 @@ class ServerBase(object): - self._inject_builtins() - self._heartbeat_freq = heartbeat - -- for (k, functor) in iteritems(self._methods): -+ for (k, functor) in self._methods.items(): - if not isinstance(functor, DecoratorBase): - self._methods[k] = rep(functor) - -@@ -102,11 +100,11 @@ class ServerBase(object): - return r - - def _zerorpc_inspect(self): -- methods = dict((m, f) for m, f in iteritems(self._methods) -+ methods = dict((m, f) for m, f in self._methods.items() - if not m.startswith('_')) - detailled_methods = dict((m, - dict(args=self._format_args_spec(f._zerorpc_args()), -- doc=f._zerorpc_doc())) for (m, f) in iteritems(methods)) -+ doc=f._zerorpc_doc())) for (m, f) in methods.items()) - return {'name': self._name, - 'methods': detailled_methods} - diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/changelog b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/changelog deleted file mode 100644 index 38b98e5e..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/changelog +++ /dev/null @@ -1,35 +0,0 @@ -zerorpc-python (0.6.3-6) testing; urgency=low - - * Remove use of the future module since not supported in Debian trixie - - -- Cedric Hombourger Mon, 06 Jan 2024 15:30:00 +0100 - -zerorpc-python (0.6.3-5) testing; urgency=low - - * Pull fix submitted upstream for zerorpc to work with pyzmq 23.0.0 (issue #251) - - -- Cedric Hombourger Fri, 20 May 2022 15:30:00 +0100 - -zerorpc-python (0.6.3-4) testing; urgency=low - - * Build-Depends against python3-all-dev - - -- Cedric Hombourger Mon, 17 Jan 2022 23:18:00 +0100 - -zerorpc-python (0.6.3-3) testing; urgency=low - - * Amend Build-Depends to support cross-compilation - - -- Cedric Hombourger Sat, 15 Jan 2022 08:06:00 +0100 - -zerorpc-python (0.6.3-2) testing; urgency=low - - * Pull sources from PyPI.org and get debian meta-data from this layer - - -- Cedric Hombourger Mon, 23 Nov 2020 16:39:36 +0100 - -zerorpc-python (0.6.3-1) testing; urgency=low - - * Package upstream version 0.6.3 - - -- Cedric Hombourger Wed, 18 Dec 2019 08:48:40 +0100 diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/compat b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/compat deleted file mode 100644 index ec635144..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/control b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/control deleted file mode 100644 index 678fb7e5..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/control +++ /dev/null @@ -1,21 +0,0 @@ -Source: zerorpc-python -Section: devel -Priority: extra -Maintainer: Cedric Hombourger -Build-Depends: debhelper (>=10), - dh-python, - libpython3-all-dev, - python3-all-dev, - python3-setuptools -Standards-Version: 4.5.0 -Homepage: https://github.com/0rpc/zerorpc-python -X-Python3-Version: >= 3.7 - -Package: python3-zerorpc -Architecture: all -Multi-Arch: foreign -Depends: ${misc:Depends}, ${python3:Depends} -Description: zerorpc for python - zerorpc is a flexible RPC implementation based on zeromq and - messagepack. Service APIs exposed with zerorpc are called - "zeroservices". diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/copyright b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/copyright deleted file mode 100644 index 8fbf1570..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/copyright +++ /dev/null @@ -1,32 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: zerorpc-python -Source: https://github.com/0rpc/zerorpc-python - -Files: setup.py - tests/*.py - zerorpc/*.py -Copyright: 2015 François-Xavier Bourlet (bombela+zerorpc@gmail.com) -License: MIT - -Files: debian/* -Copyright: 2021, Siemens Digital Industries Software -License: MIT - -License: MIT - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - . - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/rules b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/rules deleted file mode 100755 index 28764153..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/rules +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/make -f -DEB_BUILD_OPTIONS += nocheck - -%: - dh $@ --with python3 --buildsystem=pybuild diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/format b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/format deleted file mode 100644 index d3827e75..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -1.0 diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/local-options b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/local-options deleted file mode 100644 index 00131ee8..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/source/local-options +++ /dev/null @@ -1,2 +0,0 @@ -#abort-on-upstream-changes -#unapply-patches diff --git a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/watch b/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/watch deleted file mode 100644 index 76575dc5..00000000 --- a/meta-isar/recipes-python/zerorpc/files/zerorpc-0.6.3/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -# You must remove unused comment lines for the released package. -version=3 diff --git a/meta-isar/recipes-python/zerorpc/zerorpc-python_0.6.3.bb b/meta-isar/recipes-python/zerorpc/zerorpc-python_0.6.3.bb deleted file mode 100644 index 13a68184..00000000 --- a/meta-isar/recipes-python/zerorpc/zerorpc-python_0.6.3.bb +++ /dev/null @@ -1,19 +0,0 @@ -# --------------------------------------------------------------------------- -# This Isar layer is part of MTDA -# Copyright (C) 2025 Siemens AG -# --------------------------------------------------------------------------- -# SPDX-License-Identifier: MIT -# --------------------------------------------------------------------------- - -inherit dpkg - -SRC_URI = " \ - https://files.pythonhosted.org/packages/73/ff/d61ef9f5d10e671421d1368e87d3525325483ebd7da262b1d3087443662b/zerorpc-${PV}.tar.gz \ - file://0001-gevent_zmq-import-enums-from-pyzmq-23.0.0.patch \ - file://0002-do-not-use-future.patch \ - file://zerorpc-${PV}/debian \ -" - -PR = "6" -S = "${WORKDIR}/zerorpc-${PV}" -SRC_URI[sha256sum] = "d2ee247a566fc703f29c277d767f6f61f1e12f76d0402faea4bd815f32cbf37f" diff --git a/mtda-cli b/mtda-cli index 88388529..0eb00bda 100755 --- a/mtda-cli +++ b/mtda-cli @@ -14,7 +14,6 @@ import requests import time import sys -import zerorpc import socket from argparse import ArgumentParser, RawTextHelpFormatter @@ -410,13 +409,7 @@ class Application: uptime = "" if tgt_status == "ON": uptime = f" (up {self.target_uptime()})" - try: - remote_version = client.agent_version() - except (zerorpc.RemoteError) as e: - if e.name == 'NameError': - remote_version = "<=0.5" - else: - raise e + remote_version = client.agent_version() host = MultiTenantDeviceAccess() prefix_key = chr(ord(client.console_prefix_key()) + ord('a') - 1) diff --git a/mtda-service b/mtda-service index 19f81e4b..691ba0a3 100755 --- a/mtda-service +++ b/mtda-service @@ -17,9 +17,9 @@ import lockfile import netifaces import os import os.path +import Pyro4 import signal import sys -import zerorpc import socket import zeroconf from systemd import daemon as sd @@ -75,9 +75,9 @@ class Application: return False # Start our RPC server - uri = "tcp://*:%d" % (self.agent.ctrlport) - s = zerorpc.Server(self.agent, heartbeat=20) - s.bind(uri) + Pyro4.config.SERIALIZER = "marshal" + daemon = Pyro4.Daemon(port=self.agent.ctrlport) + daemon.register(self.agent, objectId="mtda.main") # Initialize ZeroConf interfaces = zeroconf.InterfaceChoice.All @@ -105,7 +105,7 @@ class Application: try: sd.notify('READY=1') - s.run() + daemon.requestLoop() except KeyboardInterrupt: self.stop() return True diff --git a/mtda/client.py b/mtda/client.py index b2b53fca..f2e064b6 100644 --- a/mtda/client.py +++ b/mtda/client.py @@ -11,12 +11,12 @@ import os +import Pyro4 import random import socket import subprocess import tempfile import time -import zerorpc import zstandard as zstd from mtda.main import MultiTenantDeviceAccess @@ -37,11 +37,10 @@ def __init__(self, host=None, session=None, config_files=None, agent = MultiTenantDeviceAccess() agent.load_config(host, config_files=config_files) if agent.remote is not None: - uri = "tcp://%s:%d" % (agent.remote, agent.ctrlport) - self._impl = zerorpc.Client( - heartbeat=min(timeout, CONSTS.RPC.HEARTBEAT), - timeout=timeout) - self._impl.connect(uri) + uri = f"PYRO:mtda.main@{agent.remote}:{agent.ctrlport}" + Pyro4.config.SERIALIZER = "marshal" + self._impl = Pyro4.Proxy(uri) + self._impl._pyroTimeout = timeout else: self._impl = agent self._agent = agent diff --git a/mtda/constants.py b/mtda/constants.py index 27683882..001f8225 100644 --- a/mtda/constants.py +++ b/mtda/constants.py @@ -52,7 +52,6 @@ class POWER: class RPC: - HEARTBEAT = 20 TIMEOUT = 2*60 diff --git a/mtda/main.py b/mtda/main.py index 4621d67f..553478a3 100644 --- a/mtda/main.py +++ b/mtda/main.py @@ -14,6 +14,7 @@ import glob import importlib import os +import Pyro4 import socket import subprocess import sys @@ -112,9 +113,11 @@ def __init__(self): if home != '': self.config_files.append(os.path.join(home, '.mtda', 'config')) + @Pyro4.expose def agent_version(self): return self.version + @Pyro4.expose def command(self, args, session=None): self.mtda.debug(3, "main.command()") @@ -157,6 +160,7 @@ def _composite_stop(self): self.mtda.debug(3, f"main._composite_stop(): {result}") return result + @Pyro4.expose def config_set_power_timeout(self, timeout, session=None): self.mtda.debug(3, "main.config_set_power_timeout()") @@ -169,6 +173,7 @@ def config_set_power_timeout(self, timeout, session=None): self.mtda.debug(3, f"main.config_set_power_timeout(): {result}") return result + @Pyro4.expose def config_set_session_timeout(self, timeout, session=None): self.mtda.debug(3, "main.config_set_session_timeout()") @@ -221,6 +226,7 @@ def console_init(self): self.console_input = ConsoleInput() self.console_input.start() + @Pyro4.expose def console_clear(self, session=None): self.mtda.debug(3, "main.console_clear()") @@ -236,6 +242,7 @@ def console_clear(self, session=None): self.mtda.debug(3, f"main.console_clear(): {str(result)}") return result + @Pyro4.expose def console_dump(self, session=None): self.mtda.debug(3, "main.console_dump()") @@ -251,6 +258,7 @@ def console_dump(self, session=None): self.mtda.debug(3, f"main.console_dump(): {str(result)}") return result + @Pyro4.expose def console_flush(self, session=None): self.mtda.debug(3, "main.console_flush()") @@ -266,6 +274,7 @@ def console_flush(self, session=None): self.mtda.debug(3, f"main.console_flush(): {str(result)}") return result + @Pyro4.expose def console_head(self, session=None): self.mtda.debug(3, "main.console_head()") @@ -277,6 +286,7 @@ def console_head(self, session=None): self.mtda.debug(3, f"main.console_head(): {str(result)}") return result + @Pyro4.expose def console_lines(self, session=None): self.mtda.debug(3, "main.console_lines()") @@ -288,6 +298,7 @@ def console_lines(self, session=None): self.mtda.debug(3, f"main.console_lines(): {str(result)}") return result + @Pyro4.expose def console_locked(self, session=None): self.mtda.debug(3, "main.console_locked()") @@ -297,6 +308,7 @@ def console_locked(self, session=None): self.mtda.debug(3, f"main.console_locked(): {str(result)}") return result + @Pyro4.expose def console_print(self, data, session=None): self.mtda.debug(3, "main.console_print()") @@ -308,6 +320,7 @@ def console_print(self, data, session=None): self.mtda.debug(3, f"main.console_print(): {str(result)}") return result + @Pyro4.expose def console_prompt(self, newPrompt=None, session=None): self.mtda.debug(3, "main.console_prompt()") @@ -339,6 +352,7 @@ def console_remote(self, host, screen): self.mtda.debug(3, f"main.console_remote(): {str(result)}") return result + @Pyro4.expose def console_run(self, cmd, session=None): self.mtda.debug(3, "main.console_run()") @@ -351,6 +365,7 @@ def console_run(self, cmd, session=None): self.mtda.debug(3, f"main.console_run(): {str(result)}") return result + @Pyro4.expose def console_send(self, data, raw=False, session=None): self.mtda.debug(3, "main.console_send()") @@ -363,6 +378,7 @@ def console_send(self, data, raw=False, session=None): self.mtda.debug(3, f"main.console_send(): {str(result)}") return result + @Pyro4.expose def console_tail(self, session=None): self.mtda.debug(3, "main.console_tail()") @@ -374,6 +390,7 @@ def console_tail(self, session=None): self.mtda.debug(3, f"main.console_tail(): {str(result)}") return result + @Pyro4.expose def console_toggle(self, session=None): self.mtda.debug(3, "main.console_toggle()") @@ -387,6 +404,7 @@ def console_toggle(self, session=None): self.mtda.debug(3, f"main.console_toggle(): {str(result)}") return result + @Pyro4.expose def console_wait(self, what, timeout=None, session=None): self.mtda.debug(3, "main.console_wait()") @@ -423,6 +441,7 @@ def warn(self, msg): def error(self, msg): print(f'error: {msg}', file=sys.stderr) + @Pyro4.expose def env_get(self, name, default=None, session=None): self.mtda.debug(3, "env_get()") @@ -433,6 +452,7 @@ def env_get(self, name, default=None, session=None): self.mtda.debug(3, f"env_get(): {str(result)}") return result + @Pyro4.expose def env_set(self, name, value, session=None): self.mtda.debug(3, "env_set()") @@ -450,6 +470,7 @@ def env_set(self, name, value, session=None): self.mtda.debug(3, f"env_set(): {str(result)}") return result + @Pyro4.expose def keyboard_write(self, what, session=None): self.mtda.debug(3, "main.keyboard_write()") @@ -514,6 +535,7 @@ def monitor_remote(self, host, screen): self.mtda.debug(3, f"main.monitor_remote(): {str(result)}") return result + @Pyro4.expose def monitor_send(self, data, raw=False, session=None): self.mtda.debug(3, "main.monitor_send()") @@ -526,6 +548,7 @@ def monitor_send(self, data, raw=False, session=None): self.mtda.debug(3, f"main.monitor_send(): {str(result)}") return result + @Pyro4.expose def monitor_wait(self, what, timeout=None, session=None): self.mtda.debug(3, "main.monitor_wait()") @@ -550,6 +573,7 @@ def pastebin_endpoint(self): self.mtda.debug(3, "main.pastebin_endpoint()") return self._pastebin_endpoint + @Pyro4.expose def power_locked(self, session=None): self.mtda.debug(3, "main.power_locked()") @@ -578,6 +602,7 @@ def _storage_event(self, status, reason=""): status = status + " " + reason self.notify(CONSTS.EVENTS.STORAGE, status) + @Pyro4.expose def storage_bytes_written(self, session=None): self.mtda.debug(3, "main.storage_bytes_written()") @@ -587,6 +612,7 @@ def storage_bytes_written(self, session=None): self.mtda.debug(3, f"main.storage_bytes_written(): {str(result)}") return result + @Pyro4.expose def storage_compression(self, compression, session=None): self.mtda.debug(3, "main.storage_compression()") @@ -600,6 +626,7 @@ def storage_compression(self, compression, session=None): self.mtda.debug(3, f"main.storage_compression(): {str(result)}") return result + @Pyro4.expose def storage_bmap_dict(self, bmapDict, session=None): self.mtda.debug(3, "main.storage_bmap_dict()") @@ -611,6 +638,7 @@ def storage_bmap_dict(self, bmapDict, session=None): result = True self.mtda.debug(3, f"main.storage_bmap_dict()(): {str(result)}") + @Pyro4.expose def storage_close(self, session=None): self.mtda.debug(3, "main.storage_close()") @@ -636,6 +664,7 @@ def storage_close(self, session=None): self.mtda.debug(3, f"main.storage_close(): {str(result)}") return result + @Pyro4.expose def storage_locked(self, session=None): self.mtda.debug(3, "main.storage_locked()") @@ -684,6 +713,7 @@ def storage_locked(self, session=None): self.mtda.debug(3, f"main.storage_locked(): {result}") return result + @Pyro4.expose def storage_mount(self, part=None, session=None): self.mtda.debug(3, "main.storage_mount()") @@ -704,6 +734,7 @@ def storage_mount(self, part=None, session=None): self.mtda.debug(3, f"main.storage_mount(): {str(result)}") return result + @Pyro4.expose def storage_update(self, dst, offset, session=None): self.mtda.debug(3, "main.storage_update()") @@ -720,6 +751,7 @@ def storage_update(self, dst, offset, session=None): self.mtda.debug(3, f"main.storage_update(): {str(result)}") return result + @Pyro4.expose def storage_network(self, session=None): self.mtda.debug(3, "main.storage_network()") @@ -752,6 +784,7 @@ def storage_network(self, session=None): self.mtda.debug(3, f"main.storage_network(): {result}") return result + @Pyro4.expose def storage_open(self, session=None): self.mtda.debug(3, 'main.storage_open()') @@ -776,6 +809,7 @@ def storage_open(self, session=None): self.mtda.debug(3, 'main.storage_open(): success') + @Pyro4.expose def storage_status(self, session=None): self.mtda.debug(3, "main.storage_status()") @@ -791,6 +825,7 @@ def storage_status(self, session=None): self.mtda.debug(3, f"main.storage_status(): {str(result)}") return result + @Pyro4.expose def storage_to_host(self, session=None): self.mtda.debug(3, "main.storage_to_host()") @@ -806,6 +841,7 @@ def storage_to_host(self, session=None): self.mtda.debug(3, f"main.storage_to_host(): {result}") return result + @Pyro4.expose def storage_to_target(self, session=None): self.mtda.debug(3, "main.storage_to_target()") @@ -822,6 +858,7 @@ def storage_to_target(self, session=None): self.mtda.debug(3, f"main.storage_to_target(): {str(result)}") return result + @Pyro4.expose def storage_swap(self, session=None): self.mtda.debug(3, "main.storage_swap()") @@ -840,6 +877,7 @@ def storage_swap(self, session=None): self.mtda.debug(3, f"main.storage_swap(): {str(result)}") return result + @Pyro4.expose def storage_write(self, data, session=None): self.mtda.debug(3, "main.storage_write()") @@ -915,6 +953,7 @@ def systemd_configure(self): self.mtda.debug(2, "main.systemd_configure(): " "no changes to systemd dropins") + @Pyro4.expose def toggle_timestamps(self): self.mtda.debug(3, "main.toggle_timestamps()") @@ -927,6 +966,7 @@ def toggle_timestamps(self): self.mtda.debug(3, f"main.toggle_timestamps(): {str(result)}") return result + @Pyro4.expose def target_lock(self, session): self.mtda.debug(3, "main.target_lock()") @@ -937,6 +977,7 @@ def target_lock(self, session): self.mtda.debug(3, f"main.target_lock: {result}") return result + @Pyro4.expose def target_locked(self, session): self.mtda.debug(3, "main.target_locked()") @@ -1043,6 +1084,7 @@ def _target_on(self, session=None): self.mtda.debug(3, f"main._target_on(): {result}") return result + @Pyro4.expose def target_on(self, session=None): self.mtda.debug(3, "main.target_on()") @@ -1105,6 +1147,7 @@ def _target_off(self, session=None): self.mtda.debug(3, f"main._target_off(): {result}") return result + @Pyro4.expose def target_off(self, session=None): self.mtda.debug(3, "main.target_off()") @@ -1131,6 +1174,7 @@ def _target_status(self, session=None): self.mtda.debug(3, f"main._target_status(): {result}") return result + @Pyro4.expose def target_status(self, session=None): self.mtda.debug(3, "main.target_status()") @@ -1140,6 +1184,7 @@ def target_status(self, session=None): self.mtda.debug(3, f"main.target_status(): {result}") return result + @Pyro4.expose def target_toggle(self, session=None): self.mtda.debug(3, "main.target_toggle()") @@ -1160,6 +1205,7 @@ def target_toggle(self, session=None): self.mtda.debug(3, f"main.target_toggle(): {result}") return result + @Pyro4.expose def target_unlock(self, session): self.mtda.debug(3, "main.target_unlock()") @@ -1170,6 +1216,7 @@ def target_unlock(self, session): self.mtda.debug(3, f"main.target_unlock: {result}") return result + @Pyro4.expose def target_uptime(self, session=None): self.mtda.debug(3, "main.target_uptime()") @@ -1200,6 +1247,7 @@ def usb_has_class(self, className, session=None): usb_switch = self.usb_find_by_class(className, session) return usb_switch is not None + @Pyro4.expose def usb_off(self, ndx, session=None): self.mtda.debug(3, "main.usb_off()") @@ -1220,6 +1268,7 @@ def usb_off_by_class(self, className, session=None): return usb_switch.off() return False + @Pyro4.expose def usb_on(self, ndx, session=None): self.mtda.debug(3, "main.usb_on()") @@ -1240,12 +1289,14 @@ def usb_on_by_class(self, className, session=None): return usb_switch.on() return False + @Pyro4.expose def usb_ports(self, session=None): self.mtda.debug(3, "main.usb_ports()") self._session_check(session) return len(self.usb_switches) + @Pyro4.expose def usb_status(self, ndx, session=None): self.mtda.debug(3, "main.usb_status()") @@ -1265,6 +1316,7 @@ def usb_status(self, ndx, session=None): return "ERR" return "???" + @Pyro4.expose def usb_toggle(self, ndx, session=None): self.mtda.debug(3, "main.usb_toggle()") @@ -1276,6 +1328,7 @@ def usb_toggle(self, ndx, session=None): except IndexError: print("invalid USB switch #" + str(ndx), file=sys.stderr) + @Pyro4.expose def video_url(self, host="", opts=None): self.mtda.debug(3, f"main.video_url(host={host}, opts={opts})") diff --git a/setup.py b/setup.py index 5fae33a9..b7178833 100644 --- a/setup.py +++ b/setup.py @@ -62,13 +62,13 @@ "netifaces>=0.11.0", "pyserial>=2.6", "python-daemon>=2.0", + "pyro4>=4.82", "pyusb>=1.0", "pyzmq>=15.0,<25.0.0", "psutil", "requests", "systemd-python>=234", "urwid", - "zerorpc>=0.6.0", "zstandard>=0.14", "zeroconf>=0.28.6" ],