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.show()
svc.show_full()
svc.status()
svc.list_dependencies()

svc.reload_daemon()

API

Systemctl(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

  • show() -> str
  • show_full() -> ShowModel
  • status() -> StatusModel
  • is_active() -> bool
  • get_main_pid() -> int
  • get_description() -> str
  • get_unit_file_state() -> str
  • list_dependencies() -> list

systemd Manager

  • reload_daemon() -> bool

License

GPL-2.0


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.0.6.tar.gz (14.7 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.0.6-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pysysctllib-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f3b828bc68981a0e6689ae9c2a412890a5f2e040de02537b21eb09081d134789
MD5 5e279106167174acde01c8b3683e6596
BLAKE2b-256 3e61d1fa90bb67f3e143939c1349882ea6d452237833600303c9da7a1f36c028

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysysctllib-0.0.6.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.0.6-py3-none-any.whl.

File metadata

  • Download URL: pysysctllib-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 20.7 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.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe4ab38f25ec65b9cd8a2e58d7fa7d5b0144289d2245b279f674e18a6007954
MD5 ccbb47c6d51a2557a1f8c3e3131b44f9
BLAKE2b-256 89e77831b7fbdd20ddf556588e4912ba8b36e294bed9587fa2275c2b87003bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysysctllib-0.0.6-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