You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"""
use sdbus to check on statue of service
"""
systemd = Systemd(sdbus.sd_bus_open_system())
try:
unit_object_path = systemd.get_unit(service)
except Exception as e:
print(f"no such unit {e}")
sys.exit()
unit = SystemdUnit(unit_object_path)
print(unit.description)
return True`
if name=="main":
service = "ssh.service"
print(f" is the the service {service} running? -> {is_service_active(service)}")
return the following errors:
pi@dawntest:/Programming/python-sdbus-wifi-connect $ cd /home/pi/Programming/python-sdbus-wifi-connect ; /usr/bin/env sudo -E /home/pi/Programming/python-sdbus-wifi-connect/venv/bin/python /home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher 38367 -- /home/pi/Programming/python-sdbus-wifi-connect/src/utility.py
Traceback (most recent call last):
File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 71, in
cli.main()
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main
run()
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 351, in run_file
runpy.run_path(target, run_name="main")
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in _run_module_code
_run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
exec(code, run_globals)
File "/home/pi/Programming/python-sdbus-wifi-connect/src/utility.py", line 212, in
print(f" is the the service {service} running? -> {is_service_active(service)}")
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/Programming/python-sdbus-wifi-connect/src/utility.py", line 203, in is_service_active
print(unit.description)
^^^^^^^^^^^^^^^^
File "/home/pi/Programming/python-sdbus-wifi-connect/venv/lib/python3.11/site-packages/sdbus/dbus_proxy_sync_property.py", line 82, in get
reply_message = obj._dbus.attached_bus.call(new_call_message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sd_bus_internals.SdBusUnmappedMessageError: ('System.Error.ENOTCONN', 'Transport endpoint is not connected')
pi@dawntest:/Programming/python-sdbus-wifi-connect $
Not sure how to actually get to the unit and its methods/properties.
The text was updated successfully, but these errors were encountered:
`def is_service_active(service: str)->bool:
if name=="main":
service = "ssh.service"
print(f" is the the service {service} running? -> {is_service_active(service)}")
return the following errors:
pi@dawntest:
/Programming/python-sdbus-wifi-connect $ cd /home/pi/Programming/python-sdbus-wifi-connect ; /usr/bin/env sudo -E /home/pi/Programming/python-sdbus-wifi-connect/venv/bin/python /home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher 38367 -- /home/pi/Programming/python-sdbus-wifi-connect/src/utility.py/Programming/python-sdbus-wifi-connect $Traceback (most recent call last):
File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/runpy.py", line 88, in _run_code
exec(code, run_globals)
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 71, in
cli.main()
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 501, in main
run()
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 351, in run_file
runpy.run_path(target, run_name="main")
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in _run_module_code
_run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
File "/home/pi/.vscode-server/extensions/ms-python.debugpy-2024.12.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
exec(code, run_globals)
File "/home/pi/Programming/python-sdbus-wifi-connect/src/utility.py", line 212, in
print(f" is the the service {service} running? -> {is_service_active(service)}")
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pi/Programming/python-sdbus-wifi-connect/src/utility.py", line 203, in is_service_active
print(unit.description)
^^^^^^^^^^^^^^^^
File "/home/pi/Programming/python-sdbus-wifi-connect/venv/lib/python3.11/site-packages/sdbus/dbus_proxy_sync_property.py", line 82, in get
reply_message = obj._dbus.attached_bus.call(new_call_message)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sd_bus_internals.SdBusUnmappedMessageError: ('System.Error.ENOTCONN', 'Transport endpoint is not connected')
pi@dawntest:
Not sure how to actually get to the unit and its methods/properties.
The text was updated successfully, but these errors were encountered: