mkbackup-btrfs/files/usr/lib/python3/dist-packages/mkbackup/service

42 lines
1.2 KiB
Text
Raw Normal View History

2019-03-05 13:20:31 +01:00
#!/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 MkBackup
#from services.notifications import AllStati
#from services.notifications import Properties
#from services.mkbackup import Properties
MkBackup(sysbus_name, "/at/xundeenergie/mkbackup/Intervals")
#AllStati(sysbus_name, "/at/xundeenergie/mkbackup")
#Properties(sysbus_name, "/at/xundeenergie/mkbackup")
#Properties(sysbus_name, dbus_interface="/at/xundeenergie/mkbackup")
loop.run()
except KeyboardInterrupt:
print("keyboard interrupt received")
except Exception as e:
print("Unexpected exception occurred: '{}'".format(str(e)))
finally:
loop.quit()