This packages uses D-Bus to control systemd. You need to have D-Bus itself and its python bindings in order to use this library. For example, on Ubuntu you need to install the following packages:
sudo apt install dbus libdbus-glib-1-dev libdbus-1-dev python-dbus
The setup.py does not contain the python-dbus
dependency and you have to install it manually.
from sysdmanager import SystemdManager
manager = SystemdManager()
if not manager.is_active("bluetooth.service"):
manager.start_unit("bluetooth.service")
SystemdManager().start_unit(unit_name, mode="replace")
unit_name
- a string in form of'*.service'
mode
- start mode. One ofreplace
,fail
,isolate
,ignore-dependencies
,ignore-requirements
. Details here- returns bool representing operation success
SystemdManager().stop_unit(unit_name, mode="replace")
unit_name
- a string in form of'*.service'
mode
- start mode. One ofreplace
,fail
,isolate
,ignore-dependencies
,ignore-requirements
. Details here- returns bool representing operation success
SystemdManager().enable_unit(unit_name)
unit_name
- a string in form of'*.service'
- returns bool representing operation success
SystemdManager().disable_unit(unit_name)
unit_name
- a string in form of'*.service'
- returns bool representing operation success
SystemdManager().is_active(unit_name)
unit_name
- a string in form of'*.service'
- returns bool representing unit state
This package was written by Aleksandr Aleksandrov and is used in Emlid's products, such as Reach and Reach RS.