Submit
Path:
~
/
/
usr
/
lib
/
python2.7
/
site-packages
/
File Content:
hwdata.py
# # Copyright (c) 1999--2012 Red Hat, Inc. # # This software is licensed to you under the GNU General Public License, # version 2 (GPLv2). There is NO WARRANTY for this software, express or # implied, including the implied warranties of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 # along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. # # Red Hat trademarks are not licensed under GPLv2. No permission is # granted to use or replicate Red Hat trademarks that are incorporated # in this software or its documentation. # """ Query hwdata database and return decription of vendor and/or device. """ class USB: """ Interace to usb.ids from hwdata package """ filename = '/usr/share/hwdata/usb.ids' devices = None def __init__(self, filename=None): """ Load pci.ids from file to internal data structure. parameter 'filename' can specify location of this file """ if filename: self.filename = filename else: self.filename = USB.filename self.cache = 1 if self.cache and not USB.devices: # parse usb.ids USB.devices = {} for line in open(self.filename).readlines(): l = line.split() if line.startswith('#'): if line.startswith('# List of known device classes, subclasses and protocols'): break # end of database of devices, rest is protocols, types etc. else: continue elif len(l) == 0: continue elif line.startswith('\t\t'): interface_id = l[0].lower() if len(l) > 2: interface_name = ' '.join(l[1:]) else: interface_name = '' USB.devices[vendor][1][device][0][interface_id] = interface_name elif line.startswith('\t'): device = l[0].lower() device_name = ' '.join(l[1:]) USB.devices[vendor][1][device] = [device_name, {}] else: vendor = l[0].lower() vendor_name = ' '.join(l[1:]) if vendor not in USB.devices: USB.devices[vendor] = [vendor_name, {}] else: # this should not happen USB.devices[vendor][0] = vendor_name def get_vendor(self, vendor): """ Return description of vendor. Parameter is two byte code in hexa. If vendor is unknown None is returned. """ vendor = vendor.lower() if self.cache: if vendor in USB.devices: return USB.devices[vendor][0] else: return None else: raise # not implemented yet def get_device(self, vendor, device): """ Return description of device. Parameters are two byte code variables in hexa. If device is unknown None is returned. """ vendor = vendor.lower() device = device.lower() if self.cache: if vendor in USB.devices: if device in USB.devices[vendor][1]: return USB.devices[vendor][1][device][0] else: return None else: return None else: raise # not implemented yet class PCI: """ Interace to pci.ids from hwdata package """ filename = '/usr/share/hwdata/pci.ids' devices = None def __init__(self, filename=None): """ Load pci.ids from file to internal data structure. parameter 'filename' can specify location of this file """ if filename: self.filename = filename else: self.filename = PCI.filename self.cache = 1 if self.cache and not PCI.devices: # parse pci.ids pcirec = {} PCI.devices = {} for line in open(self.filename).readlines(): l = line.split() if line.startswith('#'): continue elif len(l) == 0: continue elif line.startswith('\t\t'): continue elif line.startswith('\t'): device = l[0].lower() device_name = ' '.join(l[1:]) PCI.devices[vendor][1][device] = device_name else: vendor = l[0].lower() vendor_name = ' '.join(l[1:]) if not vendor in list(PCI.devices.keys()): PCI.devices[vendor] = [vendor_name, {}] else: # this should not happen PCI.devices[vendor][0] = vendor_name def get_vendor(self, vendor): """ Return description of vendor. Parameter is two byte code in hexa. If vendor is unknown None is returned. """ vendor = vendor.lower() if self.cache: if vendor in list(PCI.devices.keys()): return PCI.devices[vendor][0] else: return None else: raise # not implemented yet def get_device(self, vendor, device): """ Return description of device. Parameters are two byte code variables in hexa. If device is unknown None is returned. """ vendor = vendor.lower() device = device.lower() if self.cache: if vendor in list(PCI.devices.keys()): if device in list(PCI.devices[vendor][1].keys()): return PCI.devices[vendor][1][device] else: return None else: return None else: raise # not implemented yet
Submit
FILE
FOLDER
Name
Size
Permission
Action
Babel-0.9.6-py2.7.egg-info
---
0755
Jinja2-2.7.2-py2.7.egg-info
---
0755
_markerlib
---
0755
babel
---
0755
backports
---
0755
chardet
---
0755
chardet-2.2.1-py2.7.egg-info
---
0755
clcommon
---
0755
decorator-3.4.0-py2.7.egg-info
---
0755
iniparse
---
0755
isc
---
0755
javapackages
---
0755
javapackages-1.0.0-py2.7.egg-info
---
0755
jinja2
---
0755
kitchen
---
0755
kitchen-1.1.1-py2.7.egg-info
---
0755
ply
---
0755
procfs
---
0755
pyudev
---
0755
pyudev-0.15-py2.7.egg-info
---
0755
rhn
---
0755
rpmUtils
---
0755
setuptools
---
0755
setuptools-0.9.8-py2.7.egg-info
---
0755
tuned
---
0755
urlgrabber
---
0755
yum
---
0755
yumutils
---
0755
IPy-0.75-py2.7.egg-info
10061 bytes
0644
IPy.py
51270 bytes
0644
IPy.pyc
40873 bytes
0644
IPy.pyo
40873 bytes
0644
backports.ssl_match_hostname-3.5.0.1-py2.7.egg-info
4051 bytes
0644
clsudo.py
12953 bytes
0644
clsudo.pyc
11285 bytes
0644
clsudo.pyo
11285 bytes
0644
configobj-4.7.2-py2.7.egg-info
2135 bytes
0644
configobj.py
88163 bytes
0644
configobj.pyc
66278 bytes
0644
configobj.pyo
66278 bytes
0644
decorator.py
10639 bytes
0644
decorator.pyc
8563 bytes
0644
decorator.pyo
8516 bytes
0644
easy_install.py
126 bytes
0644
easy_install.pyc
315 bytes
0644
easy_install.pyo
315 bytes
0644
hwdata.py
6033 bytes
0644
hwdata.pyc
4487 bytes
0644
hwdata.pyo
4487 bytes
0644
iniparse-0.4-py2.7.egg-info
1083 bytes
0644
ipaddress-1.0.16-py2.7.egg-info
783 bytes
0644
ipaddress.py
79904 bytes
0644
ipaddress.pyc
75525 bytes
0644
ipaddress.pyo
75335 bytes
0644
isc-2.0-py2.7.egg-info
267 bytes
0644
pciutils-1.7.3-py2.7.egg-info
267 bytes
0644
pkg_resources.py
101108 bytes
0644
pkg_resources.pyc
108033 bytes
0644
pkg_resources.pyo
108001 bytes
0644
ply-3.4-py2.7.egg-info
900 bytes
0644
pyparsing-1.5.6-py2.7.egg-info
670 bytes
0644
pyparsing.py
155429 bytes
0644
pyparsing.pyc
148895 bytes
0644
pyparsing.pyo
148895 bytes
0644
python_linux_procfs-0.4.9-py2.7.egg-info
350 bytes
0644
rhnlib-2.5.65-py2.7.egg-info
345 bytes
0644
secureio.py
9222 bytes
0644
secureio.pyc
4686 bytes
0644
secureio.pyo
4686 bytes
0644
urlgrabber-3.10-py2.7.egg-info
2265 bytes
0644
validate.py
46303 bytes
0644
validate.pyc
46711 bytes
0644
validate.pyo
46711 bytes
0644
N4ST4R_ID | Naxtarrr