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
1
vote
0 answers

Detecting a USB keyboard with pyudev?

I've been picking through this question to try to detect a hotplug of a USB keyboard, but ID_INPUT_KEYBOARD isn't a key in the udev Device object that represents my keyboard. How can I use pyudev to detect whether or not the hotplugged device is a…
Synthead
  • 2,162
  • 5
  • 22
  • 25
0
votes
0 answers

How can I handle multiple devices as they connect and disconnect with evdev?

I am trying to use evdev to read input events on Linux asynchronously, but I want to handle devices being connected or disconnected. To make my system relatively general and compatible with multiple devices, I want a control thread that can dispatch…
zane49er
  • 31
  • 5
0
votes
0 answers

ModuleNotFoundError: No module named 'fcntl' - pycharm - win 10 - python 3.10 - pyudev

I was not planning to post this on the forum but at the moment i dont see any other solution. I have installed fresh pycharm and python 3.9 on my new windows box. At the time i must settle with windows but it will be changed in the near future to…
Arnix
  • 1
  • 2
0
votes
0 answers

USB device status update inside container

import usb import pyudev def detect_device(): dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) if dev is None: print("No device found") return False else: print("USB device found") return…
Shree
  • 1
  • 1
0
votes
1 answer

Python script for monitoring USB and copying files upon insertion

I would like to run a python script on my Raspberry Pi which basically monitors the USB ports for insertion of a USB drive. Upon insertion it should copy files from the drive onto a local folder. So far I've managed to use the pyudev library to…
Ailsor
  • 48
  • 5
0
votes
1 answer

Need to detect any usb block device with specific partition label

I'm surprised this is proving to be difficult to find. I need to detect when a USB block device with a specific partition label is added (plugged in) using python3. Is there a way to use pyudev to provide a list of USB block devices? How can I…
0
votes
1 answer

How to get the capacity of a usb pendrive?

I need to get the capacity of a usb pendrive that is unmounted. I'm using pyudev to detect it, but I don't know how to get the capacity. I read some documentation about pyusb, but I haven't found anything of useful. Any idea?
Lews
  • 426
  • 4
  • 9
0
votes
1 answer

How can i get file directory of usb device afer detect it when i placed in raspberry pi in python?

Im using pyudev for detecting when an usb device is placed in raspberry pi. But i need get file directory of it for saving a excel file in an usb after i detect it Code is: import pyudev import RPi.GPIO as GPIO import time from time import…
AndresS
  • 63
  • 1
  • 3
0
votes
1 answer

Defining a file descriptor in python3 - to work with pyudev/evdev

I'm currently trying to detect the connexion of a bluetooth button on a raspberry pi 3 (that part works) and once connected, detect when the button is pressed (that part doesn't work). I've started with the code provided by evdev and tried to tweak…
Pôm'
  • 1
  • 1
0
votes
0 answers

Checking whether a plugged in device is hotpluggable or not using udev

I have a python script to get plugged in device details. I am using udev library to manage the connected devices. From my python script I want to check whether the plugged in device is hotpluggable or not. How can I find this using udev…
pmattt
  • 1
  • 3
0
votes
1 answer

Python I have device ID how to get dev address

I have a USB device, it may not be connected to the same port everytime it is plugged into the PC, how can i find it's dev-address given that I have its UID ? import serial.tools.list_ports as port portlist = list(port.comports()) for p in…
Pratik Kumar
  • 2,211
  • 1
  • 17
  • 41
0
votes
1 answer

pyqt5 - How to add value to QComboBox fromfunction

I try to add items to QComboBox (deviceBox in my code) from function "get_devices" using "activated.connect()" method, but QComboBox is empty. Where I was mistaken? #!/usr/bin/env python3 from PyQt5.QtWidgets import QApplication, QMainWindow,…
0
votes
0 answers

How to emit GObject signal once?

First, I have less than one year experience with Python. I normally have problems with data usage with my ISP such that I discover late that I have overused my data allocation. So, in order to evade this problem, I thought of creating a script that…
omushpapa
  • 1,663
  • 20
  • 25
0
votes
1 answer

pyudev type object 'Context' has no attribute '_libudev'

I am using the pyudev library on Debian GNU/Linux 8.7 (jessie) with python2.7 to detect USB devices as follows: import sys import pyudev def main(): os = canary.helpers.get_platform_system() if os.lower() == "linux": …
user7319401
0
votes
0 answers

(Python) glib MonitorObserver return two exception when attach (or detach) usb device. Why?

I use this code to monitor usb device: context = Context() monitor = Monitor.from_netlink(context) monitor.filter_by(subsystem='usb') monitor.poll(1.5) observer = MonitorObserver(monitor) observer.connect('device-event',…
karmax
  • 171
  • 2
  • 13