示例#1
0
class USB_Service_Blocker(dbus.service.Object):
    inhibitor_work = False

    def __init__(self):
        self.usb_monitor = USB_inhibit(True)
        bus_name = dbus.service.BusName('org.gnome.USBBlocker',
                                        bus=dbus.SystemBus())
        dbus.service.Object.__init__(self, bus_name, '/org/gnome/USBBlocker')

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.inhibit', \
      in_signature='', out_signature='b')
    def get_status(self):
        return self.inhibitor_work

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.inhibit')
    def start(self):
        print("Start monitoring Dbus system message")
        if not self.inhibitor_work:
            self.usb_monitor.start()
            self.inhibitor_work = True

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.inhibit')
    def stop(self):
        print("Stop monitoring Dbus system message")
        if self.inhibitor_work:
            self.usb_monitor.stop()
            self.inhibitor_work = False

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.device',
                         in_signature='ss',
                         out_signature='b')
    def enable_device(self, bus_id, dev_id):
        print(bus_id)
        print(dev_id)

        import time
        time.sleep(0.03)
        return self.usb_monitor.bind_driver(bus_id, dev_id)
class USB_Service_Blocker(dbus.service.Object):
    inhibitor_work = False

    def __init__(self):
	self.usb_monitor = USB_inhibit(True)
	bus_name = dbus.service.BusName('org.gnome.USBBlocker', bus=dbus.SystemBus())
        dbus.service.Object.__init__(self, bus_name, '/org/gnome/USBBlocker')

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.inhibit', \
						in_signature='', out_signature='b')
    def get_status(self):
        return self.inhibitor_work
	
    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.inhibit')
    def start(self):
        print("Start monitoring Dbus system message")
        if not self.inhibitor_work:
	    self.usb_monitor.start()
            self.inhibitor_work = True
                

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.inhibit')
    def stop(self):
        print("Stop monitoring Dbus system message")
        if self.inhibitor_work:
	    self.usb_monitor.stop()
	    self.inhibitor_work = False

    @dbus.service.method(dbus_interface='org.gnome.USBBlocker.device',
                                                in_signature='ss', out_signature='b')
    def enable_device(self, bus_id, dev_id):
        print (bus_id)
        print (dev_id)

        import time; time.sleep(0.03)    
        return self.usb_monitor.bind_driver(bus_id, dev_id)
示例#3
0
 def __init__(self):
     self.usb_monitor = USB_inhibit(True)
     bus_name = dbus.service.BusName('org.gnome.USBBlocker',
                                     bus=dbus.SystemBus())
     dbus.service.Object.__init__(self, bus_name, '/org/gnome/USBBlocker')
    def __init__(self):
	self.usb_monitor = USB_inhibit(True)
	bus_name = dbus.service.BusName('org.gnome.USBBlocker', bus=dbus.SystemBus())
        dbus.service.Object.__init__(self, bus_name, '/org/gnome/USBBlocker')