pysystemd


Namepysystemd JSON
Version 1.1 PyPI version JSON
download
home_pagehttps://codeberg.org/alimiracle/pysystemd
SummaryA systemd binding Library in Python
upload_time2024-06-20 11:22:11
maintainerNone
docs_urlNone
authoralimiracle
requires_pythonNone
licenseLGPL v3
keywords services init systemd
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```python
pip install pysystemd
```
or simply clone this repository and import the required classes into your project.

## Usage

### Checking Service Status

```python
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

```python
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

```python
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

```python
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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://codeberg.org/alimiracle/pysystemd",
    "name": "pysystemd",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "services, init, systemd",
    "author": "alimiracle",
    "author_email": "alimiracle@riseup.net",
    "download_url": "https://files.pythonhosted.org/packages/06/e0/1163b05b669c68cc95c6d9fcbdc904f1fdc5df3dc831dc9b59c6676ad5d6/pysystemd-1.1.tar.gz",
    "platform": null,
    "description": "# PySystemd\n\nPySystemd 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.\n\n## Features\n\n- **ServiceStatus**: Check if a service is running or enabled, and retrieve detailed status information.\n- **ServiceManager**: Start, stop, restart, reload, enable, and disable services.\n- **ServiceLister**: List all services, running services, not running services, enabled services, and disabled services.\n- **PowerManager**: Perform power operations like power off, reboot, rescue, and suspend.\n- **SystemStatus**: Get system uptime and load average.\n\n## Installation\n\n```python\npip install pysystemd\n```\nor simply clone this repository and import the required classes into your project.\n\n## Usage\n\n### Checking Service Status\n\n```python\nfrom pysystemd import ServiceStatus\n\nservice = ServiceStatus('apache2')\nprint(service.is_running())  # Check if the service is running\nprint(service.is_enabled())  # Check if the service is enabled\nprint(service.get_status())  # Get detailed status of the service\n\n### Managing Services\n\n```python\nfrom pysystemd import ServiceManager\n\nmanager = ServiceManager('apache2')\nmanager.start()    # Start the service\nmanager.stop()     # Stop the service\nmanager.restart()  # Restart the service\nmanager.reload()   # Reload the service\nmanager.enable()   # Enable the service\nmanager.disable()  # Disable the service\n```\n\n### Listing Services\n\n```python\nfrom pysystemd import ServiceLister\n\nprint(ServiceLister.list_all())          # List all services\nprint(ServiceLister.list_running())      # List all running services\nprint(ServiceLister.list_not_running())  # List all not running services\nprint(ServiceLister.list_enabled())      # List all enabled services\nprint(ServiceLister.list_disabled())     # List all disabled services\n```\n\n### Power Management\n\n```python\nfrom pysystemd import PowerManager\n\nPowerManager.poweroff()  # Power off the system\nPowerManager.reboot()    # Reboot the system\nPowerManager.rescue()    # Boot to rescue mode\nPowerManager.suspend()   # Suspend the system\n```\n\n### System Status\n\n```python\nfrom pysystemd import SystemStatus\n\nprint(SystemStatus.uptime())        # Get system uptime\nprint(SystemStatus.load_average())  # Get system load average\n```\n\n### Logging\n\nPySystemd 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.\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit pull requests for any features, bug fixes, or improvements.\n\n### License\n\nThis project is licensed under the LGPL v3 License.\n\n",
    "bugtrack_url": null,
    "license": "LGPL v3",
    "summary": "A systemd binding Library in Python",
    "version": "1.1",
    "project_urls": {
        "Homepage": "https://codeberg.org/alimiracle/pysystemd"
    },
    "split_keywords": [
        "services",
        " init",
        " systemd"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06e01163b05b669c68cc95c6d9fcbdc904f1fdc5df3dc831dc9b59c6676ad5d6",
                "md5": "38f687fe2ff7918e8cdc9c36ea520db5",
                "sha256": "6713014b1d0ccdda42136516957d3e015615b4693aafe491f470fc28c06afab0"
            },
            "downloads": -1,
            "filename": "pysystemd-1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "38f687fe2ff7918e8cdc9c36ea520db5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6351,
            "upload_time": "2024-06-20T11:22:11",
            "upload_time_iso_8601": "2024-06-20T11:22:11.245568Z",
            "url": "https://files.pythonhosted.org/packages/06/e0/1163b05b669c68cc95c6d9fcbdc904f1fdc5df3dc831dc9b59c6676ad5d6/pysystemd-1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-20 11:22:11",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": true,
    "codeberg_user": "alimiracle",
    "codeberg_project": "pysystemd",
    "lcname": "pysystemd"
}
        
Elapsed time: 0.35708s