Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI

on:
push:
branches: [main]
tags: [v*.*.*]

pull_request:
branches: [ "main" ]
types:
- synchronize
- opened
- reopened

jobs:
call_ci:
uses: EffectiveRange/ci-workflows/.github/workflows/python-ci.yaml@test
with:
coverage-threshold: 95
65 changes: 0 additions & 65 deletions .github/workflows/test_and_release.yml

This file was deleted.

24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

[![Test and Release](https://github.com/EffectiveRange/python-systemd-dbus/actions/workflows/test_and_release.yml/badge.svg)](https://github.com/EffectiveRange/python-systemd-dbus/actions/workflows/test_and_release.yml)
[![CI](https://github.com/EffectiveRange/python-systemd-dbus/actions/workflows/ci.yaml/badge.svg)](https://github.com/EffectiveRange/python-systemd-dbus/actions/workflows/ci.yaml)
[![Coverage badge](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/EffectiveRange/python-systemd-dbus/python-coverage-comment-action-data/endpoint.json)](https://htmlpreview.github.io/?https://github.com/EffectiveRange/python-systemd-dbus/blob/python-coverage-comment-action-data/htmlcov/index.html)

# python-systemd-dbus
Expand Down Expand Up @@ -80,9 +79,10 @@ Note: `service_name` is automatically appended with `.service` if not provided.
### Start/Stop/Restart/Reload services

```python
from dbus import SystemBus
from systemd_dbus import SystemdDbus

systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())

systemd.start_service('service_name')
systemd.stop_service('service_name')
Expand All @@ -93,9 +93,10 @@ systemd.reload_service('service_name')
### Enable/Disable service files

```python
from dbus import SystemBus
from systemd_dbus import SystemdDbus

systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())

systemd.enable_service('service_name')
systemd.disable_service('service_name')
Expand All @@ -104,9 +105,10 @@ systemd.disable_service('service_name')
### Mask/Unmask service files

```python
from dbus import SystemBus
from systemd_dbus import SystemdDbus

systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())

systemd.mask_service('service_name')
systemd.unmask_service('service_name')
Expand All @@ -115,9 +117,10 @@ systemd.unmask_service('service_name')
### Get service state/error code

```python
from dbus import SystemBus
from systemd_dbus import SystemdDbus

systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())

state = systemd.get_active_state('service_name')
print(state)
Expand All @@ -129,9 +132,10 @@ print(error_code)
### Get service/service file properties

```python
from dbus import SystemBus
from systemd_dbus import SystemdDbus

systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())

properties = systemd.get_service_properties('service_name')
for key, value in properties.items():
Expand All @@ -145,9 +149,10 @@ for key, value in properties.items():
### Reload systemd daemon

```python
from dbus import SystemBus
from systemd_dbus import SystemdDbus

systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())

state = systemd.reload_daemon()
```
Expand All @@ -171,6 +176,7 @@ Output:
Example to print status changes for `dhcpcd` service:

```python
from dbus import SystemBus
from typing import Any
from systemd_dbus import SystemdDbus

Expand All @@ -182,6 +188,6 @@ def on_property_changed(*args: Any) -> None:
print(f'State of dhcpcd service changed to {state}')


systemd = SystemdDbus()
systemd = SystemdDbus(SystemBus())
systemd.add_property_change_handler('/org/freedesktop/systemd1/unit/dhcpcd_2eservice', on_property_changed)
```
2 changes: 1 addition & 1 deletion systemd_dbus/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class SystemdDbus(Systemd):
SYSTEMD_SERVICE_INTERFACE = f'{SYSTEMD_BUS_NAME}.Service'
DBUS_PROPERTIES_INTERFACE = 'org.freedesktop.DBus.Properties'

def __init__(self, system_bus: SystemBus = SystemBus()) -> None:
def __init__(self, system_bus: SystemBus) -> None:
self._system_bus = system_bus

def __enter__(self) -> 'SystemdDbus':
Expand Down
Loading