示例#1
0
def main():
    DBusGMainLoop( set_as_default = True )
    service = GwnPhone()
    support_service = SupportService( service )

    try:
        MainLoop().run()
    except KeyboardInterrupt:
        pass
示例#2
0
 def __init__(self):
     DBusGMainLoop(set_as_default=True)
     self.mem = 'ActiveChanged'
     self.dest = 'org.gnome.ScreenSaver'
     self.bus = dbus.SessionBus()
     self.loop = MainLoop()
     self.bus.add_signal_receiver(self.catch, self.mem, self.dest)
     self.paused_before = False
     self.purple_prev = None
示例#3
0
def main():
    """The main entry point for the systemd service."""
    DBusGMainLoop( set_as_default = True )

    service = ManagerService()
    support_service = SupportService()

    try:
        logger.debug( 'entering main loop' )
        MainLoop().run()
    except KeyboardInterrupt:
        pass
示例#4
0
    def __init__(self, set_as_default=True):
        DBusGMainLoop(set_as_default=set_as_default)

        self.session_bus = SessionBus()
        # WARNING, NO BORRAR la asignación a la variable name aunque ésta no se
        # use, sino Dbus restartea el servicio N veces una por cada reintento
        # del cliente.
        name = service.BusName(self.bus_name, self.session_bus)
        self._service_init()
        service.Object.__init__(self, self.session_bus, self.object_path)

        self._loop = MainLoop()
        try:
            self._loop.run()
        except KeyboardInterrupt:
            pass
示例#5
0
def pair(args):
    """
    Pair to the specified device

    Args:
        args (dict): args parsed on the command line

    Returns:
        results (dict): return message and code of the operation
    """
    def success():
        try:
            device_manager.trust_device()
            device_manager.connect_device()
            format_results({'result': 'Success', 'code': ''})
        finally:
            mainloop.quit()

    def error(err):
        try:
            if err == 'org.freedesktop.DBus.Error.NoReply' and self.dev:
                code = 'Timeout'
                device_manager.cancel_device()
            if err in ('org.bluez.Error.AuthenticationCanceled',
                       'org.bluez.Error.AuthenticationFailed',
                       'org.bluez.Error.AuthenticationRejected',
                       'org.bluez.Error.AuthenticationTimeout'):
                code = 'AuthenticationError'
            else:
                code = 'CreatingDeviceFailed'

            format_results({'result': 'Error', 'code': code})
        finally:
            mainloop.quit()

    mainloop = MainLoop()
    device_manager = DeviceManager(args.device)
    device_manager.pair_device(success, error)
    mainloop.run()
示例#6
0
        try:
            n = notify2.Notification(head, desc)
            n.add_action("yes", "Yes", boolean_callback, uid)
            n.add_action("no", "No", boolean_callback, uid)
            n.connect("closed", click_callback)
            n.show()
            return 0
        except:
            return 1


# Initialize a main loop
dbusLoop = DBusGMainLoop(set_as_default=True)
notify2.init("keystrokes", dbusLoop)

loop = MainLoop()

# Declare a name where our service can be reached
try:
    bus_name = dbus.service.BusName("com.keystrokes.notifs",
                                    bus=dbus.SessionBus(),
                                    do_not_queue=True)
    DesktopNotification(bus_name)
except dbus.exceptions.NameExistsException:
    # print("service is already running")
    logging.info("service is already running")
    sys.exit(1)

# Run the loop
try:
    loop.run()