Python dbus package for LDMud
Project description
Python D-Bus package for LDMud
These are python efuns for LDMud 3.6.2 and later for communicating over D-Bus.
It offers a very simple interface to do and receive method calls and signals.
This module doesn't offer any support for introspection. Support for
introspection can be implemented on the LPC side by providing the
org.freedesktop.DBus.Introspectable
interface.
This package contains the following efuns:
void dbus_call_method(closure callback, string bus, string path, string interface, string method, string signature, mixed args...)
void dbus_register_signal_listener(closure callback, string bus, string path, string interface, string signal)
void dbus_unregister_signal_listener(closure callback, string bus, string path, string interface, string signal)
void dbus_publish_object(object|string ob, string path, string|string*|mapping interfaces)
void dbus_emit_signal(string interface, string name, string signature, mixed args...)
All efuns are privileged, each call is checked with master->privilege_violation()
.
This package supports the following LDMud types and their D-Bus counterparts. The first entry in the D-Bus column is the type chosen when no signature is specified.
LDMud | D-Bus | Notes |
---|---|---|
int |
x (INT64), t (UINT64), i (INT32), u (UINT32), n (INT16), q (UINT16), y (BYTE), b (BOOLEAN) |
|
float |
d (DOUBLE) |
|
string |
s (STRING), o (OBJECT_PATH), g (SIGNATURE) |
|
bytes |
ay (ARRAY of BYTES) |
|
mixed* |
av (ARRAY of VARIANT), r (STRUCT) |
|
mapping |
a{?v} (ARRAY of DICT_ENTRY) |
The key type is determined by looking at the mapping and must be int, float or string. |
Usage
Prerequisites
This package also needs the ldmud-asyncio package.
Install from the python package index
The efun package can be downloaded from the python package index:
pip3 install --user ldmud-dbus
Build & install the package yourself
You can build the package yourself.
First clone the repository
git clone https://github.com/ldmud/python-dbus.git
Install the package
cd python-dbus
python3 setup.py install --user
Automatically load the modules at startup
Use startup.py as the Python startup script for LDMud. It will automatically detect the installed python efuns and load them.
You can deactivate single efuns with a configfile .ldmud-efuns
in your home directory, with the following contents
[efuns]
name_of_the_efun = off
Manually load the modules at startup
Add the following lines to your startup script:
import ldmud_dbus
ldmud_dbus.register()
Configuration
The configuration file .ldmud-efuns
in your home directrory might specify the bus and connection name to use.
[dbus]
# The bus might be 'session', 'system' or an address like 'unix:path=/var/run/dbus/system_bus_socket'.
# Default is 'session'.
bus = session
# The connection name must be composed of at least two elements consisting of alphanumeric characters
# and separated by a period character. Default is none.
name = net.ldmud.mud
Examples
Notification
This package is intended to be used with a separate D-Bus daemon used for communicating with MUD specific tools. But if you'll connect to your session daemon, then you could show some notifications:
dbus_call_method(
function void(string error, varargs mixed* result)
{
// This is called with the result (notification id).
},
"org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify", "sisssasa{sv}i",
"LDMud", 0, "dialog-information", "Greetings!", "This is a message from your running LDMud.", ({}), ([]), 5000);
Outside call
Create an object to be called from the outside:
void create()
{
// This call can also by made by another object, for example at MUD startup.
// It routes external calls for "/my/object" to this object.
// The "my.mud.interface" interface will be implemented by the dbus_* functions.
dbus_publish_object(object_name(), "/my/object", ([ "my.mud.interface": "dbus_"]));
}
void dbus_message(string str)
{
shout(str);
}
string dbus_get_version()
{
return __VERSION__;
}
You can test that with the dbus-send
utility:
dbus-send --session --type=method_call --print-reply --dest=net.ldmud.mud "/my/object" my.mud.interface.message string:'Hello, World!'
dbus-send --session --type=method_call --print-reply --dest=net.ldmud.mud "/my/object" my.mud.interface.get_version
Have fun!
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 Distribution
File details
Details for the file ldmud-dbus-0.0.2.tar.gz
.
File metadata
- Download URL: ldmud-dbus-0.0.2.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 459f30569463ea14566349af4216312176e3f600de79a9017ff31748900af5f2 |
|
MD5 | 2f23907414dff9797e1255121b57a308 |
|
BLAKE2b-256 | 555af87301411913a59804930a7e5d6f03717a7411495805097d556efbc38471 |
File details
Details for the file ldmud_dbus-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: ldmud_dbus-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c77e1f8b75f9aedc4c22439b3f8cc0c5cd396cc3c5aba3e3a0db18a61a8783e |
|
MD5 | eb80d905d38543db984dfd59ae644835 |
|
BLAKE2b-256 | 245769e5ed411e673119a86b1bdac3e5e764352fcfcd3daba9780d7d91518e88 |