mkbackup-btrfs/files/usr/lib/python3/dist-packages/mkbackup-dbus/service
2019-03-05 13:20:31 +01:00

35 lines
953 B
Python
Executable file

#!/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()