Questions tagged [pyudev]

is a LGPL licensed, pure Python 2/3 binding to libudev, the device and hardware management and information library of Linux.

Use this tag if your question is related to pyudev python library.

According to pyudev 0.17 documentation

pyudev is a LGPL licenced, pure Python 2/3 binding to libudev, the device and hardware management and information library of Linux.

Almost the complete libudev functionality is exposed. You can:

  • Enumerate devices, filtered by specific criteria (pyudev.Context)
  • Query device information, properties and attributes,
  • Monitor devices, both synchronously and asynchronously with background threads, or within the event loops of Qt (pyudev.pyqt4, pyudev.pyside), glib (pyudev.glib) and wxPython (pyudev.wx).
36 questions
6
votes
3 answers

How to detect if USB device is plugged in using python?

I want to create a script that detects once the USB drive is plugged into the computer and for now just to print in the cmd detect. Note I am using windows after my search I found that I need to use pyudev package in order to communicate with serial…
Dev Dj
  • 169
  • 2
  • 14
6
votes
5 answers

How to detect a new usb device is connected on python

I want to make something which will run on the background and only after the computer detect new device is connected the rest of the code will run, is there any elegant way to do such a thing?
Harel2320
  • 69
  • 1
  • 1
  • 4
3
votes
1 answer

Using pyudev.pyqt5 within PyQt5's event loop

I wanted to write a small application that will display usb device's name in a small text browser, when it has been inserted. I am using pyudev to do that. Instead of using pyudev's own event loop, i found out that we can integrate pyudev into qt's…
the_parzival
  • 354
  • 3
  • 19
3
votes
3 answers

PyGame Re-Initialize USB MIDI Device on Reconnect

I'm using PyGame to read a USB MIDI device, very similar to what is used here, except I run it as a background service on a Raspberry Pi. I would like to be able to disconnect and reconnect the MIDI device, and still be able to read it. I have tried…
cwshep
  • 31
  • 3
3
votes
1 answer

Retrieve USB information using pyudev with device name

I retrieve the first device information from the block subsystem. For example that a USB stick was assigned to /dev/sdb. This is all the infos I can retrieve via the block subsystem: [(u'DEVLINKS',…
rand0m
  • 903
  • 2
  • 8
  • 16
3
votes
2 answers

Finding only disk drives using pyudev

I'm looking to enumerate all hard disks on a computer using udev and specifically pyudev to enumerate everything: import pyudev context = pyudev.Context() for device in context.list_devices(subsystem='block', DEVTYPE='disk'): print "{},…
Naftuli Kay
  • 87,710
  • 93
  • 269
  • 411
2
votes
2 answers

Linux: Display names of all currently attached USB sticks on PyQt5 GUI

The following code shows the name of a new inserted USB stick in a console (as replacement for PyQt5 GUI) on Linux. Unfortunately, a pyudev.device._errors.DeviceNotFoundAtPathError appears in console as soon as you unplug the USB stick without…
Atalanttore
  • 349
  • 5
  • 22
2
votes
2 answers

Obtain device path from pyudev with python

Using pydev with python-2.7, I wish obtain the device path of connected devices. Now I use this code: from pyudev.glib import GUDevMonitorObserver as MonitorObserver def device_event(observer, action, device): print 'event {0} on device…
karmax
  • 171
  • 2
  • 13
1
vote
0 answers

How pyudev is LGPL license but libudev-dev is GPL license?

The systemd source indicating udev is GPL license: systemd$ vim LICENSES/README.md The following exceptions apply:  * some udev sources under src/udev/ are licensed under **GPL-2.0-or-later**, so the    udev binaries as a whole are also distributed…
Marco Polo
  • 11
  • 2
1
vote
1 answer

Notify QML for 'usb device inserted' events using PyQt5 and pyudev

I have a GUI application (made with PyQt5 and QML) and would like to get notify when a usb device is plugged or unplugged from the computer. After some investigation, I have found that pyudev could be the library to use. But I have trouble using it…
Juliette Marquis
  • 159
  • 1
  • 1
  • 13
1
vote
1 answer

terminate a USBdetector Thread using monitor from pyudev

I have a python script that I'm running on a remote device. There will be two different threads created. The first thread is created to monitor for USB connections to the device. class USBDetector(threading.Thread): ''' Monitor udev for…
user4339694
1
vote
2 answers

How to monitor usb devices insertion?

I am trying to monitor for USB devices when they get plugged in. A couple of test scripts fail that I am pretty sure should have worked. import pyudev context = pyudev.Context() monitor =…
boobie
  • 96
  • 2
  • 12
1
vote
2 answers

pyudev: how to get the device's "friendly" name?

I want to give a /dev/DEVICE path as input and get the device "human friendly" name as output. I was having success getting the name from ID_MODEL_ENC, like in this snippet: def dev_name(dev_path): from pyudev import Context for device in…
meleu
  • 29
  • 1
  • 7
1
vote
0 answers

How do you prevent pyudev MonitorObserver from blocking the main thread with eventlet?

**Updated I have the following, and according to the example on the pyudev readthedocs site, it should be daemon threaded. However, even coupling it with Threading, it blocks when using eventlet's monkey patching. from threading import Thread from…
Kenny Powers
  • 1,254
  • 2
  • 15
  • 25
1
vote
1 answer

Can Pyudev detect bluetooth devices?

I am writing an application which monitors some devices connected to the computer. I loop over all the devices like this : from pyudev import Context, Monitor, MonitorObserver context = Context() monitor = Monitor.from_netlink(context) for device in…
Jim
  • 416
  • 2
  • 4
  • 16
1
2 3