コード例 #1
0
    def device_changed(self, gudevice, subsystem):
        '''Called when a device has been updated'''

        dev = device.get_device_object(gudevice)
        old_dev = self.devices_tree[dev.path]
        self.devices_tree[dev.path] = dev
        self.emit('changed', dev, old_dev)
コード例 #2
0
    def device_changed(self, gudevice, subsystem):
        '''Called when a device has been updated'''

        dev = device.get_device_object(gudevice)
        old_dev = self.devices_tree[dev.path]
        self.devices_tree[dev.path] = dev
        self.emit('changed', dev, old_dev)
コード例 #3
0
    def device_removed(self, gudevice, subsystem):
        '''Called when a device has been removed from the system'''

        dev = device.get_device_object(gudevice)

        if dev in self.devices_list: self.devices_list.remove(dev)
        if self.devices_tree.has_key(dev.path): del(self.devices_tree[dev.path])

        self.emit('removed', dev)
コード例 #4
0
ファイル: devicefinder.py プロジェクト: Bredun/udev-discover
    def scan_subsystems(self, subsystems="", parent_tree=False):
        self.client = gudev.Client(subsystems)
        self.subsystems = subsystems
        self.devices_tree = {}
        self.devices_list = []

        if subsystems == "":
            subsystems = ["*"]
        for subsystem in subsystems:
            for gudevice in self.client.query_by_subsystem(subsystem):
                if parent_tree:
                    self.__explore_parent(gudevice, self.devices_tree, self.devices_list)
                else:
                    self.devices_list.append(device.get_device_object(gudevice))
                    self.devices_tree[gudevice.get_sysfs_path()] = device.get_device_object(gudevice)

        self.client.connect("uevent", self.event)
        self.parent_tree = parent_tree
コード例 #5
0
    def device_removed(self, gudevice, subsystem):
        '''Called when a device has been removed from the system'''

        dev = device.get_device_object(gudevice)

        if dev in self.devices_list: self.devices_list.remove(dev)
        if self.devices_tree.has_key(dev.path):
            del (self.devices_tree[dev.path])

        self.emit('removed', dev)
コード例 #6
0
    def device_added(self, gudevice, subsystem):
        '''Called when a device has been added to the system'''

        dev = device.get_device_object(gudevice)

        if self.parent_tree: 
            self.__explore_parent(gudevice, self.devices_tree, self.devices_list, True)
        else:
            self.devices_list.append(dev)
            self.devices_tree[dev.path] = dev
            self.emit('added', dev)
コード例 #7
0
    def scan_subsystems(self, subsystems='', parent_tree=False):
        self.client = GUdev.Client.new(subsystems)
        self.subsystems = subsystems
        self.devices_tree = {}
        self.devices_list = []

        if subsystems == '': subsystems = ['*']
        for subsystem in subsystems:
            for gudevice in self.client.query_by_subsystem(subsystem):
                if parent_tree:
                    self.__explore_parent(gudevice, self.devices_tree,
                                          self.devices_list)
                else:
                    self.devices_list.append(
                        device.get_device_object(gudevice))
                    self.devices_tree[gudevice.get_sysfs_path()] = \
                        device.get_device_object(gudevice)

        self.client.connect('uevent', self.event)
        self.parent_tree = parent_tree
コード例 #8
0
    def device_added(self, gudevice, subsystem):
        '''Called when a device has been added to the system'''

        dev = device.get_device_object(gudevice)

        if self.parent_tree:
            self.__explore_parent(gudevice, self.devices_tree,
                                  self.devices_list, True)
        else:
            self.devices_list.append(dev)
            self.devices_tree[dev.path] = dev
            self.emit('added', dev)
コード例 #9
0
    def __explore_parent(self, gudevice, devices_tree, devices_list, emit=False):
        path = gudevice.get_sysfs_path()
        parent = gudevice.get_parent()

        if parent: 
            self.__explore_parent(parent, devices_tree, devices_list, emit)

        if not devices_tree.has_key(path):
            dev = device.get_device_object(gudevice)
            devices_tree[path] = dev
            devices_list.append(dev)

            if emit:
                self.emit('added', dev)
コード例 #10
0
    def __explore_parent(self,
                         gudevice,
                         devices_tree,
                         devices_list,
                         emit=False):
        path = gudevice.get_sysfs_path()
        parent = gudevice.get_parent()

        if parent:
            self.__explore_parent(parent, devices_tree, devices_list, emit)

        if not devices_tree.has_key(path):
            dev = device.get_device_object(gudevice)
            devices_tree[path] = dev
            devices_list.append(dev)

            if emit:
                self.emit('added', dev)
コード例 #11
0
ファイル: devicefinder.py プロジェクト: ecatmur/udev-discover
    def device_changed(self, gudevice, subsystem):
        '''Called when a device has been updated'''

        dev = device.get_device_object(gudevice)
        self.emit('changed', dev)
コード例 #12
0
    def device_changed(self, gudevice, subsystem):
        '''Called when a device has been updated'''

        dev = device.get_device_object(gudevice)
        self.emit('changed', dev)
コード例 #13
0
ファイル: devicefinder.py プロジェクト: Bredun/udev-discover
    def device_changed(self, gudevice, subsystem):
        """Called when a device has been updated"""

        dev = device.get_device_object(gudevice)
        self.emit("changed", dev)