Найти - Пользователи
Полная версия: Проверка USB на наличие клавиатуры
Начало » Python для новичков » Проверка USB на наличие клавиатуры
1
ComplexTrims96
Поставил себе задачу обнаружить, присутствует ли в USB клавиатура или нет. Копаясь в сети, набрёл на команду lsusb. Присобачил сюда. Прошу помочь найти более изысканные решения, прокомментировать моё и направить в нужную сторону.
def check_keyboard_usb():
    import subprocess    
    proc = subprocess.Popen(["lsusb -v"], stdout=subprocess.PIPE, shell=True)
    (out, err) = proc.communicate()
    if "Keyboard" in out:
        return True
    else:
        return False
ZerG
import usb
for dev in usb.core.find(find_all=True):
    print "Device:", dev.filename
    print "  idVendor: %d (%s)" % (dev.idVendor, hex(dev.idVendor))
    print "  idProduct: %d (%s)" % (dev.idProduct, hex(dev.idProduct))


ну и
https://github.com/walac/pyusb/blob/master/docs/tutorial.rst
Kostilo

ZerG
ну и
https://github.com/walac/pyusb/blob/master/docs/tutorial.rst
Для python3 это работает?
ZerG
Что уже настока обленились что впадлу тыкнуть мышкой по линку и прочесть

PyUSB aims to be an easy to use Python module to access USB devices. PyUSB relies on a native system library for USB access. Currently, it works out of the box with libusb 0.1, libusb 1.0, libusbx, libusb-win32 and OpenUSB, and works with any Python version starting at 2.4, including Python 3 releases.
Kostilo
ZerG
PyUSB aims to be an easy to use Python module to access USB devices. PyUSB relies on a native system library for USB access. Currently, it works out of the box with libusb 0.1, libusb 1.0, libusbx, libusb-win32 and OpenUSB, and works with any Python version starting at 2.4, including Python 3 releases.
Я очень извиняюсь, но по приведённой Вами ссылке приведённой вами же цитаты не увидел

Ткните меня носом, где здесь ваша цитата?
ZerG
Portability:
PyUSB should run on any platform with Python >= 2.4, ctypes and at least one of the supported builtin backends.
Да уж….
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB