pystemd
Advanced tools
+18
-7
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 2.1 | ||
| Metadata-Version: 2.4 | ||
| Name: pystemd | ||
| Version: 0.14.0 | ||
| Version: 0.15.0 | ||
| Summary: A systemd binding for python | ||
@@ -16,15 +16,26 @@ Author: Alvaro Leiva Geisse | ||
| Classifier: Intended Audience :: System Administrators | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Classifier: Programming Language :: Python :: 3.10 | ||
| Classifier: Programming Language :: Python :: 3.11 | ||
| Classifier: Programming Language :: Python :: 3.12 | ||
| Classifier: Programming Language :: Python :: 3.13 | ||
| Classifier: Programming Language :: Python :: 3.14 | ||
| Classifier: Development Status :: 5 - Production/Stable | ||
| Classifier: Topic :: Utilities | ||
| Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) | ||
| Requires-Python: >=3.11 | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| Requires-Dist: lxml | ||
| Requires-Dist: psutil | ||
| Provides-Extra: t | ||
| Requires-Dist: pytest; extra == "t" | ||
| Requires-Dist: pytest-cov; extra == "t" | ||
| Requires-Dist: cstq; extra == "t" | ||
| Requires-Dist: toml; extra == "t" | ||
| Provides-Extra: lint | ||
| License-File: LICENSE | ||
| Requires-Dist: ruff; extra == "lint" | ||
| Requires-Dist: pyrefly; extra == "lint" | ||
| Requires-Dist: isort; extra == "lint" | ||
| Dynamic: author | ||
| Dynamic: license-file | ||
@@ -31,0 +42,0 @@ pystemd |
+9
-12
@@ -7,5 +7,6 @@ [build-system] | ||
| name = "pystemd" | ||
| version = "0.14.0" | ||
| version = "0.15.0" | ||
| readme = "README.md" | ||
| description="A systemd binding for python" | ||
| requires-python=">=3.11" | ||
| dependencies = [ | ||
@@ -25,8 +26,7 @@ "lxml", | ||
| "Intended Audience :: System Administrators", | ||
| "Programming Language :: Python :: 3.6", | ||
| "Programming Language :: Python :: 3.7", | ||
| "Programming Language :: Python :: 3.8", | ||
| "Programming Language :: Python :: 3.9", | ||
| "Programming Language :: Python :: 3.10", | ||
| "Programming Language :: Python :: 3.11", | ||
| "Programming Language :: Python :: 3.12", | ||
| "Programming Language :: Python :: 3.13", | ||
| "Programming Language :: Python :: 3.14", | ||
| "Development Status :: 5 - Production/Stable", | ||
@@ -45,7 +45,8 @@ "Topic :: Utilities", | ||
| # cstq and toml are used for testing version | ||
| "cstq", "toml" | ||
| "cstq", | ||
| "toml", | ||
| ] | ||
| lint = [ | ||
| "black", | ||
| "mypi", | ||
| "ruff", | ||
| "pyrefly", | ||
| "isort", | ||
@@ -59,6 +60,2 @@ ] | ||
| [tool.mypy] | ||
| strict = false | ||
| packages = ["pystemd"] | ||
| [tool.isort] | ||
@@ -65,0 +62,0 @@ atomic = true |
@@ -1,4 +0,4 @@ | ||
| Metadata-Version: 2.1 | ||
| Metadata-Version: 2.4 | ||
| Name: pystemd | ||
| Version: 0.14.0 | ||
| Version: 0.15.0 | ||
| Summary: A systemd binding for python | ||
@@ -16,15 +16,26 @@ Author: Alvaro Leiva Geisse | ||
| Classifier: Intended Audience :: System Administrators | ||
| Classifier: Programming Language :: Python :: 3.6 | ||
| Classifier: Programming Language :: Python :: 3.7 | ||
| Classifier: Programming Language :: Python :: 3.8 | ||
| Classifier: Programming Language :: Python :: 3.9 | ||
| Classifier: Programming Language :: Python :: 3.10 | ||
| Classifier: Programming Language :: Python :: 3.11 | ||
| Classifier: Programming Language :: Python :: 3.12 | ||
| Classifier: Programming Language :: Python :: 3.13 | ||
| Classifier: Programming Language :: Python :: 3.14 | ||
| Classifier: Development Status :: 5 - Production/Stable | ||
| Classifier: Topic :: Utilities | ||
| Classifier: License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+) | ||
| Requires-Python: >=3.11 | ||
| Description-Content-Type: text/markdown | ||
| License-File: LICENSE | ||
| Requires-Dist: lxml | ||
| Requires-Dist: psutil | ||
| Provides-Extra: t | ||
| Requires-Dist: pytest; extra == "t" | ||
| Requires-Dist: pytest-cov; extra == "t" | ||
| Requires-Dist: cstq; extra == "t" | ||
| Requires-Dist: toml; extra == "t" | ||
| Provides-Extra: lint | ||
| License-File: LICENSE | ||
| Requires-Dist: ruff; extra == "lint" | ||
| Requires-Dist: pyrefly; extra == "lint" | ||
| Requires-Dist: isort; extra == "lint" | ||
| Dynamic: author | ||
| Dynamic: license-file | ||
@@ -31,0 +42,0 @@ pystemd |
@@ -5,4 +5,4 @@ lxml | ||
| [lint] | ||
| black | ||
| mypi | ||
| ruff | ||
| pyrefly | ||
| isort | ||
@@ -9,0 +9,0 @@ |
@@ -10,3 +10,2 @@ LICENSE | ||
| pystemd/base.py | ||
| pystemd/base.pyi | ||
| pystemd/cutils.c | ||
@@ -13,0 +12,0 @@ pystemd/cutils.pyi |
@@ -11,3 +11,3 @@ # | ||
| from pystemd import DBus, __version__, machine1, systemd1 | ||
| from pystemd import machine1, systemd1 | ||
@@ -14,0 +14,0 @@ SDUnit = systemd1.Unit |
@@ -13,4 +13,4 @@ # | ||
| # latest release. | ||
| __version__ = "0.14.0" | ||
| __version__ = "0.15.0" | ||
| sys.modules[__name__] = __version__ # type: ignore |
+22
-12
@@ -8,5 +8,7 @@ # | ||
| # | ||
| from __future__ import annotations | ||
| import re | ||
| from contextlib import contextmanager | ||
| from typing import AnyStr, Iterator, Optional | ||
@@ -20,3 +22,9 @@ from lxml import etree | ||
| class SDObject(object): | ||
| def __init__(self, destination, path, bus=None, _autoload=False): | ||
| def __init__( | ||
| self, | ||
| destination: AnyStr, | ||
| path: AnyStr, | ||
| bus: Optional[DBus] = None, | ||
| _autoload: bool = False, | ||
| ): | ||
| self.destination = x2char_star(destination) | ||
@@ -40,10 +48,10 @@ self.path = x2char_star(path) | ||
| def __setstate__(self, state): | ||
| def __setstate__(self, state) -> None: | ||
| self.__init__(**state) | ||
| def __enter__(self): | ||
| def __enter__(self) -> SDObject: | ||
| self.load() | ||
| return self | ||
| def __exit__(self, exception_type, exception_value, traceback): | ||
| def __exit__(self, exception_type, exception_value, traceback) -> None: | ||
| pass | ||
@@ -63,3 +71,3 @@ | ||
| # methods and/or properties. But in the meantime, we can trust that | ||
| # the fine folks at systemd will not do this. they have actually go | ||
| # the fine folks at systemd will not do this. They have actually go | ||
| # out of their way to make this true: | ||
@@ -74,3 +82,3 @@ # https://github.com/systemd/systemd/blob/119f0f2876ea340cc41525e844487aa88551c219/src/core/dbus-unit.c#L1738-L1746 | ||
| @contextmanager | ||
| def bus_context(self): | ||
| def bus_context(self) -> Iterator[DBus]: | ||
| close_bus_at_end = self._bus is None | ||
@@ -88,3 +96,3 @@ try: | ||
| def get_introspect_xml(self): | ||
| def get_introspect_xml(self) -> etree._Element: | ||
| with self.bus_context() as bus: | ||
@@ -103,3 +111,3 @@ xml_doc = etree.fromstring( | ||
| def load(self, force=False): | ||
| def load(self, force=False) -> Optional[bool]: | ||
| if self._loaded and not force: | ||
@@ -137,7 +145,9 @@ return | ||
| class SDInterface(object): | ||
| def __init__(self, sd_object, interface_name): | ||
| def __init__(self, sd_object: SDObject, interface_name: AnyStr) -> None: | ||
| self.sd_object = sd_object | ||
| self.interface_name = x2char_star(interface_name) | ||
| self._properties_xml = getattr(self, "_properties_xml", {}) | ||
| self._methods_xml = getattr(self, "_methods_xml", {}) | ||
| def __repr__(self): | ||
| def __repr__(self) -> str: | ||
| return "<%s of %s>" % (self.interface_name, self.sd_object.path.decode()) | ||
@@ -156,3 +166,3 @@ | ||
| def _set_property(self, property_name, value): | ||
| def _set_property(self, property_name, value) -> None: | ||
| prop_access = self._properties_xml[property_name].attrib.get("access") | ||
@@ -194,3 +204,3 @@ if prop_access == "read": | ||
| raise NotImplementedError( | ||
| "still not implemented methods with complex " "arguments" | ||
| "still not implemented methods with complex arguments" | ||
| ) | ||
@@ -197,0 +207,0 @@ |
@@ -16,4 +16,4 @@ # Copyright (c) 2020-present, Facebook, Inc. | ||
| def listen_fds(unset_environment: bool) -> int: ... | ||
| def notify(unset_environment: bool, *args: str, **kwargs: Union[int, str]) -> None: ... | ||
| def notify(unset_environment: bool, *args: Union[str, bytes], **kwargs: Union[int, str]) -> None: ... | ||
| def booted() -> bool: ... | ||
| def watchdog_enabled(unset_environment: bool) -> int: ... |
@@ -57,4 +57,11 @@ # Copyright (c) 2020-present, Facebook, Inc. | ||
| def compile_args(*args) -> list:... | ||
| def compile_array(*args):... | ||
| def compile_simple(*args):... | ||
| def compile_struct(*args):... | ||
| def find_closure(args:bytes, open:int, close:int) -> int:... | ||
| def apply_signature(signature: bytes, values: List[Any]) -> list[Tuple[int, Any]]: ... | ||
| def path_encode(prefix: bytes, external_id: bytes) -> bytes: ... | ||
| def path_decode(path: bytes, prefix: bytes) -> bytes: ... |
+18
-1
| import os | ||
| from concurrent.futures import ProcessPoolExecutor | ||
| from functools import cached_property | ||
| from multiprocessing import Process | ||
@@ -13,2 +14,3 @@ from multiprocessing.context import BaseContext | ||
| import pystemd.utils | ||
| from pystemd.dbuslib import DBus | ||
@@ -28,2 +30,3 @@ | ||
| user_mode: bool = False, | ||
| unit_name: Optional[str] = None, | ||
| ) -> None: | ||
@@ -33,2 +36,3 @@ self.unit: Optional[pystemd.systemd1.Unit] = None | ||
| self.user_mode = user_mode | ||
| self.unit_name = unit_name | ||
| self.main_process_cmd = main_process or [ | ||
@@ -43,4 +47,6 @@ "/bin/bash", | ||
| assert self.unit is None, "Unit already started" | ||
| # pyrefly: ignore [not-callable] | ||
| self.unit = pystemd.run( | ||
| self.main_process_cmd, | ||
| name=self.unit_name, | ||
| user_mode=self.user_mode, | ||
@@ -102,2 +108,3 @@ extra={ | ||
| def pre_run(self): | ||
| # pyrefly: ignore [missing-argument] | ||
| self.original_run() | ||
@@ -129,5 +136,6 @@ | ||
| def __init__(self, *, properties=None, user_mode=False, **kwargs) -> None: | ||
| def __init__(self, *, properties=None, user_mode=False, unit_name=None, **kwargs) -> None: | ||
| super().__init__(**kwargs) | ||
| self.user_mode = user_mode | ||
| self.unit_name = unit_name or pystemd.utils.random_unit_name(prefix="pystemd-future-") | ||
| self.properties = { | ||
@@ -137,6 +145,14 @@ pystemd.utils.x2char_star(k): v for k, v in (properties or {}).items() | ||
| @cached_property | ||
| def unit(self): | ||
| bus = DBus(user_mode=self.user_mode) | ||
| bus.__enter__() | ||
| return pystemd.systemd1.Unit(self.unit_name, bus, _autoload=True) | ||
| def pre_run(self): | ||
| context = TransientUnitContext( | ||
| # pyrefly: ignore [bad-argument-type] | ||
| properties=self.properties, | ||
| user_mode=self.user_mode, | ||
| unit_name=self.unit_name, | ||
| main_process=[ | ||
@@ -163,2 +179,3 @@ "/bin/bash", | ||
| ) | ||
| # pyrefly: ignore [no-matching-overload] | ||
| super().__init__(**{**kwargs, "mp_context": self.pool_transient_unit_context}) | ||
@@ -165,0 +182,0 @@ |
@@ -26,2 +26,3 @@ # | ||
| # pyrefly: ignore [bad-override] | ||
| def __getstate__(self): | ||
@@ -28,0 +29,0 @@ return { |
+30
-6
@@ -16,3 +16,2 @@ # | ||
| import tty | ||
| import uuid | ||
| from contextlib import ExitStack | ||
@@ -26,3 +25,3 @@ from selectors import EVENT_READ, DefaultSelector | ||
| from pystemd.systemd1 import Unit | ||
| from pystemd.utils import x2char_star, x2cmdlist | ||
| from pystemd.utils import random_unit_name, x2char_star, x2cmdlist | ||
@@ -144,2 +143,3 @@ EXIT_SUBSTATES = (b"exited", b"failed", b"dead") | ||
| if address: | ||
| # pyrefly: ignore [missing-argument] | ||
| return DBusAddress(x2char_star(address)) | ||
@@ -151,3 +151,3 @@ elif machine: | ||
| name = x2char_star(name or "pystemd{}.service".format(uuid.uuid4().hex)) | ||
| name = x2char_star(name or random_unit_name()) | ||
| runtime_max_usec = (runtime_max_sec or 0) * 10**6 or runtime_max_sec | ||
@@ -169,5 +169,8 @@ | ||
| with ExitStack() as ctexit, DefaultSelector() as sel, bus_factory() as bus, SDManager( | ||
| bus=bus | ||
| ) as manager: | ||
| with ( | ||
| ExitStack() as ctexit, | ||
| DefaultSelector() as sel, | ||
| bus_factory() as bus, | ||
| SDManager(bus=bus) as manager, | ||
| ): | ||
| if pty: | ||
@@ -199,5 +202,9 @@ if machine: | ||
| # attributes as they where after this method is done | ||
| # pyrefly: ignore [missing-attribute] | ||
| stdin_attrs = tty.tcgetattr(stdin) | ||
| # pyrefly: ignore [bad-argument-type] | ||
| tty.setraw(stdin) | ||
| # pyrefly: ignore [missing-attribute] | ||
| ctexit.callback(tty.tcsetattr, stdin, tty.TCSAFLUSH, stdin_attrs) | ||
| # pyrefly: ignore [bad-argument-type] | ||
| sel.register(stdin, EVENT_READ) | ||
@@ -207,11 +214,16 @@ | ||
| if os.getenv("TERM"): | ||
| # pyrefly: ignore [missing-attribute] | ||
| env[b"TERM"] = env.get(b"TERM", os.getenv("TERM").encode()) | ||
| # pyrefly: ignore [bad-argument-type] | ||
| sel.register(pty_master, EVENT_READ) | ||
| # lets be a friend and set the size of the pty. | ||
| # pyrefly: ignore [no-matching-overload] | ||
| winsize = fcntl.ioctl( | ||
| stdout, termios.TIOCGWINSZ, struct.pack("HHHH", 0, 0, 0, 0) | ||
| ) | ||
| # pyrefly: ignore [no-matching-overload] | ||
| fcntl.ioctl(pty_master, termios.TIOCSWINSZ, winsize) | ||
| else: | ||
| # pyrefly: ignore [no-matching-overload] | ||
| unit_properties.update( | ||
@@ -229,2 +241,3 @@ { | ||
| # pyrefly: ignore [no-matching-overload] | ||
| unit_properties.update( | ||
@@ -274,2 +287,3 @@ { | ||
| # pyrefly: ignore [implicit-import] | ||
| monitor = pystemd.DBus.Manager(bus=monbus, _autoload=True) | ||
@@ -282,2 +296,3 @@ monitor.Monitoring.BecomeMonitor([mstr], 0) | ||
| # start the process | ||
| # pyrefly: ignore [missing-argument] | ||
| unit_start_job = manager.Manager.StartTransientUnit( | ||
@@ -292,3 +307,5 @@ name, b"fail", unit_properties | ||
| if stdin in _in: | ||
| # pyrefly: ignore [bad-argument-type] | ||
| data = os.read(stdin, 1024) | ||
| # pyrefly: ignore [bad-argument-type] | ||
| os.write(pty_master, data) | ||
@@ -298,9 +315,14 @@ | ||
| try: | ||
| # pyrefly: ignore [bad-argument-type] | ||
| data = os.read(pty_master, 1024) | ||
| except OSError: | ||
| # pyrefly: ignore [bad-argument-type] | ||
| sel.unregister(pty_master) | ||
| else: | ||
| # pyrefly: ignore [bad-argument-type] | ||
| os.write(stdout, data) | ||
| # pyrefly: ignore [unbound-name] | ||
| if monitor_fd in _in: | ||
| # pyrefly: ignore [unbound-name] | ||
| m = monbus.process() | ||
@@ -312,2 +334,3 @@ if m.is_empty(): | ||
| if ( | ||
| # pyrefly: ignore [missing-attribute] | ||
| m.get_path() == unit.path | ||
@@ -338,2 +361,3 @@ and m.body[0] == b"org.freedesktop.systemd1.Unit" | ||
| unit.load() | ||
| # pyrefly: ignore [bad-assignment] | ||
| unit.bus_context = bus_factory | ||
@@ -340,0 +364,0 @@ return unit |
@@ -46,3 +46,6 @@ # | ||
| def StartUnitReplace( | ||
| self, arg0: bytes, arg1: bytes, arg2: bytes # s # s # s | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bytes, | ||
| arg2: bytes, # s # s # s | ||
| ) -> bytes: ... # o | ||
@@ -54,6 +57,11 @@ def ReloadUnit(self, arg0: bytes, arg1: bytes) -> bytes: ... # s # s # o | ||
| def ReloadOrTryRestartUnit( | ||
| self, arg0: bytes, arg1: bytes # s # s | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bytes, # s # s | ||
| ) -> bytes: ... # o | ||
| def EnqueueUnitJob( | ||
| self, arg0: bytes, arg1: bytes, arg2: bytes # s # s # s | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bytes, | ||
| arg2: bytes, # s # s # s | ||
| ) -> Tuple[ | ||
@@ -68,6 +76,10 @@ int, bytes, bytes, bytes, bytes, List[Tuple[int, bytes, bytes, bytes, bytes]] | ||
| def GetUnitProcesses( | ||
| self, arg0: bytes # s | ||
| self, | ||
| arg0: bytes, # s | ||
| ) -> List[Tuple[bytes, int, bytes]]: ... # a(sus) | ||
| def AttachProcessesToUnit( | ||
| self, arg0: bytes, arg1: bytes, arg2: List[int] # s # s # au | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bytes, | ||
| arg2: List[int], # s # s # au | ||
| ) -> None: ... | ||
@@ -77,6 +89,8 @@ def AbandonScope(self, arg0: bytes) -> None: ... # s | ||
| def GetJobAfter( | ||
| self, arg0: int # u | ||
| self, | ||
| arg0: int, # u | ||
| ) -> List[Tuple[int, bytes, bytes, bytes, bytes, bytes]]: ... # a(usssoo) | ||
| def GetJobBefore( | ||
| self, arg0: int # u | ||
| self, | ||
| arg0: int, # u | ||
| ) -> List[Tuple[int, bytes, bytes, bytes, bytes, bytes]]: ... # a(usssoo) | ||
@@ -92,3 +106,4 @@ def CancelJob(self, arg0: int) -> None: ... # u | ||
| def ListUnitsFiltered( | ||
| self, arg0: List[bytes] # as | ||
| self, | ||
| arg0: List[bytes], # as | ||
| ) -> List[ | ||
@@ -98,3 +113,5 @@ Tuple[bytes, bytes, bytes, bytes, bytes, bytes, bytes, int, bytes, bytes] | ||
| def ListUnitsByPatterns( | ||
| self, arg0: List[bytes], arg1: List[bytes] # as # as | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: List[bytes], # as # as | ||
| ) -> List[ | ||
@@ -104,3 +121,4 @@ Tuple[bytes, bytes, bytes, bytes, bytes, bytes, bytes, int, bytes, bytes] | ||
| def ListUnitsByNames( | ||
| self, arg0: List[bytes] # as | ||
| self, | ||
| arg0: List[bytes], # as | ||
| ) -> List[ | ||
@@ -127,17 +145,30 @@ Tuple[bytes, bytes, bytes, bytes, bytes, bytes, bytes, int, bytes, bytes] | ||
| def UnsetAndSetEnvironment( | ||
| self, arg0: List[bytes], arg1: List[bytes] # as # as | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: List[bytes], # as # as | ||
| ) -> None: ... | ||
| def ListUnitFiles(self) -> List[Tuple[bytes, bytes]]: ... # a(ss) | ||
| def ListUnitFilesByPatterns( | ||
| self, arg0: List[bytes], arg1: List[bytes] # as # as | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: List[bytes], # as # as | ||
| ) -> List[Tuple[bytes, bytes]]: ... # a(ss) | ||
| def GetUnitFileState(self, arg0: bytes) -> bytes: ... # s # s | ||
| def ReenableUnitFiles( | ||
| self, arg0: List[bytes], arg1: bool, arg2: bool # as # b # b | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: bool, | ||
| arg2: bool, # as # b # b | ||
| ) -> Tuple[bool, List[Tuple[bytes, bytes, bytes]]]: ... # (ba(sss)) | ||
| def LinkUnitFiles( | ||
| self, arg0: List[bytes], arg1: bool, arg2: bool # as # b # b | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: bool, | ||
| arg2: bool, # as # b # b | ||
| ) -> List[Tuple[bytes, bytes, bytes]]: ... # a(sss) | ||
| def PresetUnitFiles( | ||
| self, arg0: List[bytes], arg1: bool, arg2: bool # as # b # b | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: bool, | ||
| arg2: bool, # as # b # b | ||
| ) -> Tuple[bool, List[Tuple[bytes, bytes, bytes]]]: ... # (ba(sss)) | ||
@@ -152,16 +183,27 @@ def PresetUnitFilesWithMode( | ||
| def MaskUnitFiles( | ||
| self, arg0: List[bytes], arg1: bool, arg2: bool # as # b # b | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: bool, | ||
| arg2: bool, # as # b # b | ||
| ) -> List[Tuple[bytes, bytes, bytes]]: ... # a(sss) | ||
| def UnmaskUnitFiles( | ||
| self, arg0: List[bytes], arg1: bool # as # b | ||
| self, | ||
| arg0: List[bytes], | ||
| arg1: bool, # as # b | ||
| ) -> List[Tuple[bytes, bytes, bytes]]: ... # a(sss) | ||
| def RevertUnitFiles( | ||
| self, arg0: List[bytes] # as | ||
| self, | ||
| arg0: List[bytes], # as | ||
| ) -> List[Tuple[bytes, bytes, bytes]]: ... # a(sss) | ||
| def SetDefaultTarget( | ||
| self, arg0: bytes, arg1: bool # s # b | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bool, # s # b | ||
| ) -> List[Tuple[bytes, bytes, bytes]]: ... # a(sss) | ||
| def GetDefaultTarget(self) -> bytes: ... # s | ||
| def PresetAllUnitFiles( | ||
| self, arg0: bytes, arg1: bool, arg2: bool # s # b # b | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bool, | ||
| arg2: bool, # s # b # b | ||
| ) -> List[Tuple[bytes, bytes, bytes]]: ... # a(sss) | ||
@@ -177,3 +219,5 @@ def AddDependencyUnitFiles( | ||
| def GetUnitFileLinks( | ||
| self, arg0: bytes, arg1: bool # s # b | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bool, # s # b | ||
| ) -> List[bytes]: ... # as | ||
@@ -180,0 +224,0 @@ def SetExitCode(self, arg0: int) -> None: ... # y |
@@ -380,2 +380,3 @@ # | ||
| args = [(ord(b"a"), b"(sv)")] | ||
| # pyrefly: ignore [bad-assignment] | ||
| for prop_name, prop_value in properties.items(): | ||
@@ -382,0 +383,0 @@ prop_name = x2char_star(prop_name) |
@@ -25,2 +25,3 @@ # | ||
| # pyrefly: ignore [bad-override] | ||
| def __getstate__(self): | ||
@@ -27,0 +28,0 @@ return { |
@@ -9,7 +9,6 @@ # | ||
| from typing import Any, AnyStr, Iterator, List, Optional, Tuple | ||
| from typing import Any, AnyStr, List, Optional, Tuple | ||
| from pystemd.base import SDInterface, SDObject | ||
| from pystemd.dbuslib import DBus, path_encode | ||
| from pystemd.utils import x2char_star | ||
| from pystemd.dbuslib import DBus | ||
@@ -110,3 +109,5 @@ class Unit_Unit(SDInterface): | ||
| def EnqueueJob( | ||
| self, arg0: bytes, arg1: bytes # s # s | ||
| self, | ||
| arg0: bytes, | ||
| arg1: bytes, # s # s | ||
| ) -> Tuple[ | ||
@@ -117,3 +118,5 @@ int, bytes, bytes, bytes, bytes, List[Tuple[int, bytes, bytes, bytes, bytes]] | ||
| def SetProperties( | ||
| self, arg0: bool, arg1: List[Tuple[bytes, Any]] # b # a(sv) | ||
| self, | ||
| arg0: bool, | ||
| arg1: List[Tuple[bytes, Any]], # b # a(sv) | ||
| ) -> None: ... | ||
@@ -120,0 +123,0 @@ def Ref(self) -> None: ... |
+4
-0
@@ -10,2 +10,3 @@ # | ||
| import shlex | ||
| import uuid | ||
| from pathlib import Path | ||
@@ -122,1 +123,4 @@ from typing import Any, Iterable, List, Optional, Tuple, TypeVar, Union | ||
| return obj | ||
| def random_unit_name(*, unit_type="service", prefix="pystemd"): | ||
| return f"{prefix}{uuid.uuid4().hex}.{unit_type}" |
+1
-1
@@ -66,3 +66,3 @@ #!/usr/bin/env python3 | ||
| name="pystemd", | ||
| version="0.14.0", | ||
| version="0.15.0", | ||
| author="Alvaro Leiva Geisse", | ||
@@ -69,0 +69,0 @@ author_email="aleivag@gmail.com", |
@@ -56,2 +56,3 @@ #!/usr/bin/env python3 | ||
| # present in python3.5 | ||
| # pyrefly: ignore [missing-attribute] | ||
| self.assertEqual(obj._bus.get_property.call_count, 1) | ||
@@ -63,2 +64,3 @@ | ||
| # present in python3.5 | ||
| # pyrefly: ignore [missing-attribute] | ||
| self.assertEqual(obj._bus.call_method.call_count, 1) | ||
@@ -65,0 +67,0 @@ |
@@ -18,3 +18,7 @@ #!/usr/bin/env python3 | ||
| notify_status = daemon.notify( | ||
| False, "STATUS=one...", b"STATUS=two....", status="last..." | ||
| # pyrefly: ignore [bad-argument-type] | ||
| False, | ||
| "STATUS=one...", | ||
| b"STATUS=two....", | ||
| status="last...", | ||
| ) | ||
@@ -21,0 +25,0 @@ self.assertIn(notify_status, {0, 1}) |
@@ -12,3 +12,3 @@ #!/usr/bin/env python3 | ||
| from pystemd.dbuslib import ( | ||
| from pystemd.dbuslib import ( # pyrefly: ignore [missing-module-attribute] | ||
| compile_args, | ||
@@ -15,0 +15,0 @@ compile_array, |
@@ -49,2 +49,3 @@ #!/usr/bin/env python3 | ||
| # pyrefly: ignore [missing-argument] | ||
| dbus = DBusAddress(self.dbus_address_from_unix_socket_path(socket_path)) | ||
@@ -58,2 +59,3 @@ with self.assertRaises(DBusConnectionRefusedError) as expectation: | ||
| socket_path = pathlib.Path(temporary_directory) / "test_socket" | ||
| # pyrefly: ignore [missing-argument] | ||
| dbus = DBusAddress(self.dbus_address_from_unix_socket_path(socket_path)) | ||
@@ -60,0 +62,0 @@ with self.assertRaises(DBusFileNotFoundError) as expectation: |
@@ -72,4 +72,5 @@ #!/usr/bin/env fbpython | ||
| @patch.object(pystemd.futures, "TransientUnitContext", autospec=True) | ||
| @patch("pystemd.utils.random_unit_name", autospec=True, return_value="pystemd-future-test.service") | ||
| class TestTransientUnitProcess(unittest.TestCase): | ||
| def test_pre_run(self, TransientUnitContext: MagicMock, enter_unit: Mock): | ||
| def test_pre_run(self, random_unit_name: MagicMock, TransientUnitContext: MagicMock, enter_unit: Mock): | ||
| properties = {b"foo": b"bar"} | ||
@@ -80,5 +81,7 @@ target = Mock() | ||
| p.pre_run() | ||
| random_unit_name.assert_called_once_with(prefix="pystemd-future-") | ||
| TransientUnitContext.assert_called_once_with( | ||
| properties=properties, | ||
| user_mode=False, | ||
| unit_name="pystemd-future-test.service", | ||
| main_process=[ | ||
@@ -85,0 +88,0 @@ "/bin/bash", |
@@ -15,2 +15,3 @@ from pathlib import Path | ||
| setup_version = ( | ||
| # pyrefly: ignore [missing-attribute] | ||
| Query(setup) | ||
@@ -17,0 +18,0 @@ .find_function_call(func_name="setup") |
| # | ||
| # Copyright (c) 2020-present, Facebook, Inc. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the license found in the LICENSE file in | ||
| # the root directory of this source tree. | ||
| # | ||
| import re | ||
| from contextlib import contextmanager | ||
| from typing import Any, AnyStr, Iterator, Optional | ||
| from xml.dom.minidom import Element | ||
| from pystemd.dbuslib import DBus, apply_signature | ||
| from pystemd.utils import x2char_star | ||
| class SDObject(object): | ||
| def __init__( | ||
| self, | ||
| destination: AnyStr, | ||
| path: AnyStr, | ||
| bus=Optional[DBus], | ||
| _autoload: bool = False, | ||
| ) -> None: ... | ||
| def __enter__(self) -> SDObject: ... | ||
| @contextmanager | ||
| def bus_context(self) -> Iterator[DBus]: ... | ||
| def get_introspect_xml(self) -> Element: ... | ||
| def load(self, force: bool = False) -> None: ... | ||
| class SDInterface(object): | ||
| def __init__(self, sd_object: SDObject, interface_name: AnyStr) -> None: ... | ||
| def __repr__(self) -> str: ... | ||
| def _get_property(self, property_name: str) -> Any: ... | ||
| def _set_property(self, property_name: AnyStr, value: Any) -> None: ... |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
3276982
1.23%2755
3.34%55
-1.79%