Last active
June 6, 2021 10:57
-
-
Save mothsART/44171e526a9183f4dfea90a87b600952 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import dbus | |
| from gi.repository import GLib | |
| from dbus.mainloop.glib import DBusGMainLoop | |
| BUS_NAME = 'org.essai.blabla' | |
| def get_url(): | |
| bus = dbus.SessionBus() | |
| try: | |
| remote_object = bus.get_object( | |
| BUS_NAME, | |
| "/SomeObject" | |
| ) | |
| url = remote_object.url(dbus_interface = BUS_NAME) | |
| except dbus.DBusException: | |
| print_exc() | |
| exit(1) | |
| return url | |
| if __name__ == '__main__': | |
| loop = GLib.MainLoop() | |
| url = get_url() | |
| print(url) | |
| loop.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| import dbus | |
| import dbus.service | |
| import dbus.mainloop.glib | |
| from gi.repository import GLib | |
| BUS_NAME = 'org.essai.blabla' | |
| class SomeObject(dbus.service.Object): | |
| @dbus.service.method(BUS_NAME) | |
| def url(self): | |
| return "mon url" | |
| @dbus.service.method(BUS_NAME, | |
| in_signature='', out_signature='') | |
| def Exit(self): | |
| mainloop.quit() | |
| if __name__ == '__main__': | |
| dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | |
| mainloop = GLib.MainLoop() | |
| session_bus = dbus.SessionBus() | |
| name = dbus.service.BusName(BUS_NAME, session_bus) | |
| object = SomeObject(session_bus, '/SomeObject') | |
| mainloop.run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Unit] | |
| Description=mon service de test | |
| [Service] | |
| ExecStart=/usr/bin/script-server | |
| # Restart the service on non-zero exit code when terminated by a signal other than SIGHUP, SIGINT, SIGTERM or SIGPIPE | |
| Restart=on-failure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment