36 lines
953 B
Text
36 lines
953 B
Text
|
#!/usr/bin/python3 -d
|
||
|
#!/usr/bin/env python3
|
||
|
|
||
|
import dbus, dbus.service, dbus.exceptions
|
||
|
import sys
|
||
|
|
||
|
from dbus.mainloop.glib import DBusGMainLoop
|
||
|
from gi.repository import GLib
|
||
|
|
||
|
# Initialize a main loop
|
||
|
DBusGMainLoop(set_as_default=True)
|
||
|
loop = GLib.MainLoop()
|
||
|
|
||
|
# Declare a name where our service can be reached
|
||
|
try:
|
||
|
sysbus_name = dbus.service.BusName("at.xundeenergie",
|
||
|
bus=dbus.SystemBus(),
|
||
|
do_not_queue=True)
|
||
|
except dbus.exceptions.NameExistsException:
|
||
|
print("service is already running")
|
||
|
sys.exit(1)
|
||
|
|
||
|
# Run the loop
|
||
|
try:
|
||
|
# Create our initial objects
|
||
|
from services.mkbackup import MkBackupDBus
|
||
|
MkBackupDBus(sysbus_name, "/at/xundeenergie/mkbackup/Intervals")
|
||
|
|
||
|
loop.run()
|
||
|
except KeyboardInterrupt:
|
||
|
print("keyboard interrupt received")
|
||
|
except Exception as e:
|
||
|
print("Unexpected exception occurred: '{}'".format(str(e)))
|
||
|
finally:
|
||
|
loop.quit()
|