Simple python API to control systemd services
Branch: master
Clone or download
Latest commit ae583ac Jun 8, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sysdmanager Ported to Python3 Jun 8, 2018
tests
.gitignore
LICENSE
MANIFEST.in
Makefile general: minor formatting changes Oct 5, 2017
README.md readme: make better use of markdown, add prerequisities and small Oct 6, 2017
setup.py setup.py: switch to bsd-3 license, version bump to 0.1.1, use find_pa… Oct 6, 2017

README.md

Simple python D-Bus API to control systemd services

Prerequisities

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.

Example
from sysdmanager import SystemdManager

manager = SystemdManager()
if not manager.is_active("bluetooth.service"):
    manager.start_unit("bluetooth.service")

API
  • SystemdManager().start_unit(unit_name, mode="replace")
    • unit_name - a string in form of '*.service'
    • mode - start mode. One of replace, 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 of replace, 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
Credits

This package was written by Aleksandr Aleksandrov and is used in Emlid's products, such as Reach and Reach RS.