PySystemd
PySystemd is a Python library for managing and interacting with system services using systemd. This library provides functionality to check the status of services, manage service states, list services, manage power operations, and retrieve system status information.
Features
- ServiceStatus: Check if a service is running or enabled, and retrieve detailed status information.
- ServiceManager: Start, stop, restart, reload, enable, and disable services.
- ServiceLister: List all services, running services, not running services, enabled services, and disabled services.
- PowerManager: Perform power operations like power off, reboot, rescue, and suspend.
- SystemStatus: Get system uptime and load average.
Installation
pip install pysystemd
or simply clone this repository and import the required classes into your project.
Usage
Checking Service Status
from pysystemd import ServiceStatus
service = ServiceStatus('apache2')
print(service.is_running()) # Check if the service is running
print(service.is_enabled()) # Check if the service is enabled
print(service.get_status()) # Get detailed status of the service
### Managing Services
```python
from pysystemd import ServiceManager
manager = ServiceManager('apache2')
manager.start() # Start the service
manager.stop() # Stop the service
manager.restart() # Restart the service
manager.reload() # Reload the service
manager.enable() # Enable the service
manager.disable() # Disable the service
Listing Services
from pysystemd import ServiceLister
print(ServiceLister.list_all()) # List all services
print(ServiceLister.list_running()) # List all running services
print(ServiceLister.list_not_running()) # List all not running services
print(ServiceLister.list_enabled()) # List all enabled services
print(ServiceLister.list_disabled()) # List all disabled services
Power Management
from pysystemd import PowerManager
PowerManager.poweroff() # Power off the system
PowerManager.reboot() # Reboot the system
PowerManager.rescue() # Boot to rescue mode
PowerManager.suspend() # Suspend the system
System Status
from pysystemd import SystemStatus
print(SystemStatus.uptime()) # Get system uptime
print(SystemStatus.load_average()) # Get system load average
Logging
PySystemd uses Python's built-in logging module to provide detailed logs of its operations. By default, the logging level is set to INFO and the format includes the timestamp, log level, and message.
Contributing
Contributions are welcome! Please fork the repository and submit pull requests for any features, bug fixes, or improvements.
License
This project is licensed under the LGPL v3 License.
Metadata
Release files for pysystemd 1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysystemd-1.1.tar.gz | 6.4 kB | Without provenance | Details for pysystemd-1.1.tar.gz |
Release files / pysystemd-1.1.tar.gz
| Download URL | pysystemd-1.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6713014b1d0ccdda42136516957d3e015615b4693aafe491f470fc28c06afab0
|
|
BLAKE2b-256 checksum How to use checksums |
06e01163b05b669c68cc95c6d9fcbdc904f1fdc5df3dc831dc9b59c6676ad5d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.12
|
Security for pysystemd 1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.