Skip to main content

Simple libarary for controlling systemd services

Project description

Python-Systemctl-Library

Python library providing a direct interface to systemd via systemctl for service management and inspection.

The library exposes a single high-level class, Systemctl, mapping one-to-one to common systemctl operations and queries.


Installation

From PyPI:

pip install pysysctllib

From source:

git clone https://github.com/Sesdear/Python-Systemctl-Libary.git
cd Python-Systemctl-Libary
pip install .

Environment

  • Python >= 3.7
  • Linux with systemd
  • systemctl available
  • Appropriate privileges for service control

Basic Usage

from pysysctllib import Systemctl

svc = Systemctl("nginx.service")

svc.start() 
svc.stop()
svc.restart()
svc.reload()

svc.enable()
svc.disable()

svc.mask()
svc.unmask()

svc.is_active()
svc.is_enabled()
svc.is_masked()

svc.properites()
svc.status()
svc.list_dependencies()
svc.unit_file_state()
svc.main_pid()


svc.reload_daemon()

API

Systemctl(service_name: str)

Service unit controller bound to a specific systemd unit name.


Lifecycle Operations

  • start() -> bool
  • stop() -> bool
  • restart() -> bool
  • reload() -> bool

Enablement

  • enable() -> bool
  • disable() -> bool
  • is_enabled() -> bool

Masking

  • mask() -> bool
  • unmask() -> bool
  • is_masked() -> bool

State and Metadata

  • properites() -> dict
  • status() -> StatusModel
  • is_active() -> bool
  • main_pid() -> int
  • unit_file_state() -> str
  • list_dependencies() -> list

systemd Manager

  • reload_daemon() -> bool

License

Library use GPL-2.0 License.


Author

Sesdear

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysysctllib-0.1.0.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysysctllib-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file pysysctllib-0.1.0.tar.gz.

File metadata

  • Download URL: pysysctllib-0.1.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pysysctllib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4946da738d25d82bff478e98069730e654fb771e08c23fd53659df63201e5f45
MD5 9ad517e2877793e313177a5358a0c326
BLAKE2b-256 151642666ef1b8e1bb69908e0412d2a6dc8d4d8186a8e66e83165a684c21dcdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysysctllib-0.1.0.tar.gz:

Publisher: python-publish.yml on Sesdear/Python-Systemctl-Library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysysctllib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pysysctllib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pysysctllib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f9c165b9e32538c9eeed64cf4c3f730bcadc67b7f3032c9800ec85611e3551b
MD5 184b83d8e8b14f885c8062db3fd9c979
BLAKE2b-256 29106b5aa6fe9811d9465fac790b2773c1540bd02e54e4f1ea6694c321946fc6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysysctllib-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on Sesdear/Python-Systemctl-Library

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page