Python C library for SD-Bus communication
Project description
pysysdc

Python3.5+ sd-bus adapter which allows to manage services, publish and call methods, natively control systemd units.
Tested on Ubuntu 16.04 and Ubuntu 20.04.
Idea
If you are orchestrating a large number of services on a Linux system, you have to run the command service or systemctl quite frequently.
If you want to do this programmatically, you have to start the process in most cases with a shell (to parse systemctl commands arguments) which sometimes may lead you to arguments symbols escaping.
What will do the systemctl restart nginx.service command in the end? This command will send message over SD-Bus to systemd daemon (PID 1) which will restart nginx service.
What if it is possible to send the message to systemd through the SD-Bus directly from Python? What if the same mechanism can be used for IPC?
How to compile
sudo apt update
sudo apt install python3-setuptools python3-stdeb python3-all-dev libsystemd-dev dh-python
python3 ./setup.py build
How to build DEB package
Just run build.sh and make sure you installed fakeroot package.
sudo apt update
sudo apt install fakeroot python3-setuptools python3-stdeb python3-all-dev libsystemd-dev
./build.sh
How to use
For example you can reload nginx service in the following way:
import pysysdc.systemctl as systemctl
systemctl(svc="nginx", action="reload")
All supported unit methods can be found here.
It's also possible to set your hostname through this library without any subprocess spawn, configuration editing and etc:
from pysysdc.methods import Methods
Methods.set_pretty_hostname("myhostname")
or reboot your machine
from pysysdc.methods import Methods
Methods.machine_reboot()
see other implemented systemd methods here.
Also you can publish method in you service.
from pysysdc.sdbus import SDServer
token_data = "Zm9yaDhhOWViZWJjMjYxZmU1MTVlOTlhNjczMWE3NWQ3N2ZiOjoyMDQ3NzY6Omh0dHA6Ly9yZWdpb25zZWZmZWN0aXZlLmNvbS86Ojo6MTUxMDczMjE6OjY2NDcxNDo6MDo6MTo6MTo6OjowOjpkZWZhdWx0Ojow"
def token(arg: str) -> tuple:
print("Hello from handler token().")
print("Function runned with argument: '%s'." % arg)
return True, token_data
def config(mode: str, data: str) -> tuple:
print("Hello from handler config().")
print("Mode: '%s'" % mode)
print("Data: '%s'" % data)
return True, 'done', 'test', 10
sd = SDServer(
(
{"path": "/dc/cloud/auth",
"if_name": "dc.cloud.auth",
"method_name": "Token",
"input_sig": "s",
"output_sig": "is",
"method_handler": token},
{"path": "/dc/cloud/auth",
"if_name": "dc.cloud.auth.config",
"method_name": "Config",
"input_sig": "ss",
"output_sig": "issi",
"method_handler": config},
)
)
sd.listen() # blocking
and call it from another program
from pysysdc.sdbus import SDClient
sd = SDClient(
service_name="dc.cloud.auth",
path="/dc/cloud/auth",
if_name="dc.cloud.auth",
method_name="Token",
input_sig="s",
output_sig="is"
)
ret = sd.send(method_name="Token", first_arg="get")
print(ret)
print(repr(ret))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysysdc-2.0.8.tar.gz.
File metadata
- Download URL: pysysdc-2.0.8.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d2e5e9690ea36e3752143ed90764e6786972e9bd19f3f4d2df31792d202713d
|
|
| MD5 |
c84377d7a6ece4d43e33b921f488bacd
|
|
| BLAKE2b-256 |
11b629c07252092a1ec450911bf5890af28b1432f9f8d8c7732e9005d0626cf6
|
File details
Details for the file pysysdc-2.0.8-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-pp39-pypy39_pp73-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: PyPy, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73b901e3163e187d2880661d6b7b7a76a11e7d4d59497aeae4f1f51eb51992f7
|
|
| MD5 |
bd0b0dd3569f22395aa4cd10f415d260
|
|
| BLAKE2b-256 |
72a768e23805b6c6ab1b9ed85c39ba9e7d94fefbc644c0c5b53938818e849497
|
File details
Details for the file pysysdc-2.0.8-pp39-pypy39_pp73-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-pp39-pypy39_pp73-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: PyPy, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be8985ff2bd96bf2c6aab249be925dc16a4868050d226c85cdbf0ea2d3e9ccb2
|
|
| MD5 |
24b5618959dbd2665cdf06e0acb71bbe
|
|
| BLAKE2b-256 |
cd7d83fc29b7a1ed02d4b4207fc0deeb495fcb0149aed89edb30a8b5528950bd
|
File details
Details for the file pysysdc-2.0.8-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-pp38-pypy38_pp73-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: PyPy, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf6e046d051cbd48b5f92b8acf01a44f40f792485bb52c5631d669ffce4e0bf1
|
|
| MD5 |
5ad7b84584a718bbde0389a5791663e3
|
|
| BLAKE2b-256 |
908274c674687647586329c9e5a7014632fb0ab94b17375a5685d6f6bbe601de
|
File details
Details for the file pysysdc-2.0.8-pp38-pypy38_pp73-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-pp38-pypy38_pp73-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: PyPy, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8edff0d0b2eed0e53bc364b778adff855e8a0582533cf32ca072f300b57ade1a
|
|
| MD5 |
b9333d459282ce97b067bfa33a8b642d
|
|
| BLAKE2b-256 |
56a53ed907837c3f0ff9c59d8f9188590bd24e95821b717a06e1086bdd1bd3ea
|
File details
Details for the file pysysdc-2.0.8-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-pp37-pypy37_pp73-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: PyPy, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
916a84ebabaece4897c83beb8a80a3427810a59beb988379c6c0c7119fee0749
|
|
| MD5 |
ef3d683bbd043629dc201171addec527
|
|
| BLAKE2b-256 |
b3082a7ff0092b8693df841a5c3f2b3138b94cdb1d157c08dac8e229d89091a0
|
File details
Details for the file pysysdc-2.0.8-pp37-pypy37_pp73-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-pp37-pypy37_pp73-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: PyPy, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19acd799db9478fa1bae04c33c2a9aff0dd8b24b8b4bf7448a4d2148b6349c87
|
|
| MD5 |
28e1b66aeabf0d06e10463a12e1be1c6
|
|
| BLAKE2b-256 |
abc49eb11332d32671e4406d6740e08ff6445d79ebe56f02a9cab4e1d90eaff2
|
File details
Details for the file pysysdc-2.0.8-cp311-cp311-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp311-cp311-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22c7c24950ae371b1d6cbcadbe451dc149870ee6e3b0a0029cc77ba663fdd6c7
|
|
| MD5 |
0abc4630bd4ddf04700f050704afe180
|
|
| BLAKE2b-256 |
1f7bea9efef5c16896af673f91f4870cbd50368985d874ce2d7a8593721f0133
|
File details
Details for the file pysysdc-2.0.8-cp311-cp311-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp311-cp311-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa6158ef6c99cd00e6feec70318a32df1a387a7134efba1bce04d68a988f872e
|
|
| MD5 |
deba6c5a2e54e8f0f39487ff8180dd0a
|
|
| BLAKE2b-256 |
6444702503bee22e03512cc10a7f5cc8e14bdbf0addb2b72d3a29025825dee45
|
File details
Details for the file pysysdc-2.0.8-cp310-cp310-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp310-cp310-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2fbbda5c38cd283145ccce15ed849f693c68d0548b47800afa327d8ae1d882d
|
|
| MD5 |
1eabfbf2035c9901978698342853bd00
|
|
| BLAKE2b-256 |
b21845c2607f1a8fa3b9a046c93c649dfebebb97f9e91188ce4278b064396951
|
File details
Details for the file pysysdc-2.0.8-cp310-cp310-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp310-cp310-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.10, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e77bdd324fb22eac7ac6767e6999a07b45aa39c352a87b517fad4108e3ab63a
|
|
| MD5 |
9775211b78a7704295edcbfc1a4c8f36
|
|
| BLAKE2b-256 |
7c6b16a6ba29f7cf06abb6525104fbfe21655a4b73ede26356c83e6ef23edc60
|
File details
Details for the file pysysdc-2.0.8-cp39-cp39-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp39-cp39-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d8954b781c4f6e7034644fdcb2494217c4575978d61b0442fb6afe82af63b6f
|
|
| MD5 |
de064ad28a347babc5090b45d26b2bdf
|
|
| BLAKE2b-256 |
6ad4d3aec45981cd278d28b6fd12a3029c66bf68bb81636a50a43202deb88388
|
File details
Details for the file pysysdc-2.0.8-cp39-cp39-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp39-cp39-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.9, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66331c23b75b416469d92ab1bc135cc097ea3e2305f21dbe2305dcdf89f13e74
|
|
| MD5 |
6410b53a976e35ef65719f58a8eb314a
|
|
| BLAKE2b-256 |
8ecb037031853a85ebac5396814306fa589af62441da06a169bd253d25d14710
|
File details
Details for the file pysysdc-2.0.8-cp38-cp38-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp38-cp38-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b0844e6518150bbf2cfc5fc7809e49e7ce079e23e10aa77f8dc2d0e29908104
|
|
| MD5 |
4ede55e8295cd61c4e9e6ae1de18f200
|
|
| BLAKE2b-256 |
146eae02a9086a1738d08ee501946c5933518cd096ed8f178d9a4e2d09e64f62
|
File details
Details for the file pysysdc-2.0.8-cp38-cp38-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp38-cp38-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5dad2a6cf03c98d59c2eb4f4f795c2ba07e5912f54280250e3a86f9d0afc03c
|
|
| MD5 |
d5d4861fd5868bb0a88638ece6196a39
|
|
| BLAKE2b-256 |
04d3a4a29795928d17f0c1ff606052f742ded437268fb870230e0847daa7e740
|
File details
Details for the file pysysdc-2.0.8-cp37-cp37m-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp37-cp37m-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7m, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a215c38190031d3024c27c84c2163301ff52afc04a8312de44c52d84dba4a72
|
|
| MD5 |
f403082dccb14719e3fccaeca345087e
|
|
| BLAKE2b-256 |
d21a22304035fe386c317e5c4f8c1fe4f2cbc0c38dbbbd87346e5162da487588
|
File details
Details for the file pysysdc-2.0.8-cp37-cp37m-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp37-cp37m-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.7m, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ed07f8db1ab03321ad26c2fe9a86c6426552b4afa5077ba3ed0592267cf5e05
|
|
| MD5 |
ff6152421f1659d449c97d0467b04b45
|
|
| BLAKE2b-256 |
6f572c2ff5e020045e0231c156450dc76de8f078d796cc3a19817662796d0453
|
File details
Details for the file pysysdc-2.0.8-cp36-cp36m-manylinux_2_24_x86_64.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp36-cp36m-manylinux_2_24_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.6m, manylinux: glibc 2.24+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87261e23c78eaa74ff53ed09667cdb451c6dc0859de3dde67d2d05cf0427d156
|
|
| MD5 |
caf15cc964e7aae48b9ab9aa6c8ec14b
|
|
| BLAKE2b-256 |
47d74beec91170d48bab3010bb65d60822ec65bd99a39971e0ed632a65149c04
|
File details
Details for the file pysysdc-2.0.8-cp36-cp36m-manylinux_2_24_i686.whl.
File metadata
- Download URL: pysysdc-2.0.8-cp36-cp36m-manylinux_2_24_i686.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.6m, manylinux: glibc 2.24+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3cdbe2671f9b7138d0b76410e6c81bd1c1bec8ac764e746d2c9977c708c1b297
|
|
| MD5 |
7984f180c8ea4381e177cd9c8d2ca761
|
|
| BLAKE2b-256 |
0f65c05245eb7c93fbe4c9bc44a920a79c404e4bfe8d4cb470c2e2427378a965
|