# -*- coding: utf-8 -*- # Copyright (C) 2010, 2011, 2012 Sebastian Wiesner <lunaryorn@googlemail.com> # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation; either version 2.1 of the License, or (at your # option) any later version. # This library is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # You should have received a copy of the GNU Lesser General Public License # along with this library; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ pyudev._qt_base =============== Base mixin class for Qt4 support. .. moduleauthor:: Sebastian Wiesner <lunaryorn@googlemail.com> """ from __future__ import (print_function, division, unicode_literals, absolute_import) class QUDevMonitorObserverMixin(object): def _setup_notifier(self, monitor, notifier_class): self.monitor = monitor self.notifier = notifier_class( monitor.fileno(), notifier_class.Read, self) self.notifier.activated[int].connect(self._process_udev_event) self._action_signal_map = { 'add': self.deviceAdded, 'remove': self.deviceRemoved, 'change': self.deviceChanged, 'move': self.deviceMoved, } @property def enabled(self): """ Whether this observer is enabled or not. If ``True`` (the default), this observer is enabled, and emits events. Otherwise it is disabled and does not emit any events. This merely reflects the state of the ``enabled`` property of the underlying :attr:`notifier`. .. versionadded:: 0.14 """ return self.notifier.isEnabled() @enabled.setter def enabled(self, value): self.notifier.setEnabled(value) def _process_udev_event(self): """ Attempt to receive a single device event from the monitor, process the event and emit corresponding signals. Called by ``QSocketNotifier``, if data is available on the udev monitoring socket. """ event = self.monitor.receive_device() if event: action, device = event self.deviceEvent.emit(action, device) self._action_signal_map[action].emit(device)
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
.__init__.pyo.40009 | File | 1.21 KB | 0644 |
|
._compat.pyo.40009 | File | 1019 B | 0644 |
|
._libudev.pyo.40009 | File | 8.6 KB | 0644 |
|
._py2util.pyo.40009 | File | 870 B | 0644 |
|
._py3util.pyo.40009 | File | 688 B | 0644 |
|
._qt_base.pyo.40009 | File | 2.48 KB | 0644 |
|
._util.pyo.40009 | File | 5.3 KB | 0644 |
|
.core.pyo.40009 | File | 14.9 KB | 0644 |
|
.device.pyo.40009 | File | 38.74 KB | 0644 |
|
.glib.pyo.40009 | File | 3.42 KB | 0644 |
|
.monitor.pyo.40009 | File | 17.17 KB | 0644 |
|
.pyqt4.pyo.40009 | File | 2.37 KB | 0644 |
|
.pyside.pyo.40009 | File | 2.38 KB | 0644 |
|
.wx.pyo.40009 | File | 3.7 KB | 0644 |
|
__init__.py | File | 1.75 KB | 0644 |
|
__init__.pyc | File | 1.21 KB | 0644 |
|
__init__.pyo | File | 1.21 KB | 0644 |
|
_compat.py | File | 1.44 KB | 0644 |
|
_compat.pyc | File | 1019 B | 0644 |
|
_compat.pyo | File | 1019 B | 0644 |
|
_libudev.py | File | 9.9 KB | 0644 |
|
_libudev.pyc | File | 8.6 KB | 0644 |
|
_libudev.pyo | File | 8.6 KB | 0644 |
|
_py2util.py | File | 1.32 KB | 0644 |
|
_py2util.pyc | File | 870 B | 0644 |
|
_py2util.pyo | File | 870 B | 0644 |
|
_py3util.py | File | 1.19 KB | 0644 |
|
_py3util.pyc | File | 688 B | 0644 |
|
_py3util.pyo | File | 688 B | 0644 |
|
_qt_base.py | File | 2.53 KB | 0644 |
|
_qt_base.pyc | File | 2.48 KB | 0644 |
|
_qt_base.pyo | File | 2.48 KB | 0644 |
|
_util.py | File | 5.62 KB | 0644 |
|
_util.pyc | File | 5.3 KB | 0644 |
|
_util.pyo | File | 5.3 KB | 0644 |
|
core.py | File | 13.66 KB | 0644 |
|
core.pyc | File | 14.9 KB | 0644 |
|
core.pyo | File | 14.9 KB | 0644 |
|
device.py | File | 33.43 KB | 0644 |
|
device.pyc | File | 38.74 KB | 0644 |
|
device.pyo | File | 38.74 KB | 0644 |
|
glib.py | File | 4.49 KB | 0644 |
|
glib.pyc | File | 3.42 KB | 0644 |
|
glib.pyo | File | 3.42 KB | 0644 |
|
monitor.py | File | 16.91 KB | 0644 |
|
monitor.pyc | File | 17.17 KB | 0644 |
|
monitor.pyo | File | 17.17 KB | 0644 |
|
pyqt4.py | File | 2.85 KB | 0644 |
|
pyqt4.pyc | File | 2.37 KB | 0644 |
|
pyqt4.pyo | File | 2.37 KB | 0644 |
|
pyside.py | File | 2.83 KB | 0644 |
|
pyside.pyc | File | 2.38 KB | 0644 |
|
pyside.pyo | File | 2.38 KB | 0644 |
|
wx.py | File | 3.44 KB | 0644 |
|
wx.pyc | File | 3.7 KB | 0644 |
|
wx.pyo | File | 3.7 KB | 0644 |
|