Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

list devices python 3

import re
import subprocess
device_re = re.compile(b"Buss+(?P<bus>d+)s+Devices+(?P<device>d+).+IDs(?P<id>w+:w+)s(?P<tag>.+)$", re.I)
df = subprocess.check_output("lsusb")
devices = []
for i in df.split(b'
'):
    if i:
        info = device_re.match(i)
        if info:
            dinfo = info.groupdict()
            dinfo['device'] = '/dev/bus/usb/%s/%s' % (dinfo.pop('bus'), dinfo.pop('device'))
            devices.append(dinfo)
            
print(devices)
Comment

PREVIOUS NEXT
Code Example
Python :: mkvirtualenv 
Python :: folium add a polygon to a map 
Python :: write str in a formal way in python 
Python :: merge python list items by index one after one 
Python :: save csv with today date pandas 
Python :: kali linux run python script anywhere 
Python :: is 2 an even number 
Python :: pandas impute with mean of grupby 
Python :: add service files in setup.py ROS2 
Python :: 144/360 
Python :: pytest handling muliple cases 
Python :: python [a]*b means [a,a,...b times] 
Python :: cython could not creat pyd file no such file or directory 
Python :: Create an identical list from the first list using list comprehension. 
Python :: is console and terminal is same in spyder python(3.9) 
Python :: numpy move columns 
Python :: connect two mathod to the same button in pyq5 
Python :: how to use wbtools in python 
Python :: torch.nn.Linear(in_features, out_features, bias=True) discription 
Python :: python matrix condensed to square 
Python :: mudopy 
Python :: prefetched_related django rest framework 
Python :: get all view port type dynamo revit 
Python :: fibonacci sequence python code 
Python :: how to check if a column exists before alter the table 
Python :: RuntimeError: cuda runtime error (711) : peer mapping resources exhausted at /pytorch/aten/src/THC/THCGeneral.cpp:139 
Python :: sum of values with none 
Python :: how to make a series in python alternating between + and - 
Python :: djago get settings 
Python :: inline_ternary(if)_condition 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =