Skip to content

getsenic/systemd-manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Simple python API to control systemd services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.7%
  • Makefile 1.3%