aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--h-client/hlibrary.py69
1 files changed, 43 insertions, 26 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 0b3613c..2ae684d 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -108,6 +108,7 @@ class Device(object):
def htmlentitiesDecode(self,string):
for entity,code in htmlentitydefs.name2codepoint.iteritems():
string = string.replace("&"+entity+";",unichr(code))
+ string = string.replace("'","'")
return string.encode('utf-8')
#get the h-source distro code from the codename
@@ -518,7 +519,7 @@ class Client:
'type' : 'webcam',
'controller': 'webcams'
},
- '255255255' : {
+ 'ffffff' : {
'type' : 'unknown',
'controller': 'unknown'
}
@@ -584,7 +585,11 @@ class Client:
return Videocard()
elif Class == '070100' or Class == '070101' or Class == '070102' or Class == '070103' or Class == '0701ff':
return Printer()
- elif Class == '255255255':
+ elif Class == '0e0100':
+ return Webcam()
+ elif Class == 'e00101':
+ return Bluetooth()
+ elif Class == 'ffffff':
return Unknown()
else:
return None
@@ -741,6 +746,7 @@ class Client:
deviceDict = {}
keyNumber = 0
+ usbDeviceIsFound = 'N'
while 1:
row = f.readline()
@@ -751,6 +757,7 @@ class Client:
#clear pid and vid if a new device has been found
if row.find('Device Descriptor:') != -1 and row.find('HID Device Descriptor:') == -1:
+ usbDeviceIsFound = 'N'
keyNumber = keyNumber + 1
keyString = str(keyNumber)
deviceDict[keyString] = {}
@@ -771,41 +778,51 @@ class Client:
deviceDict[keyString]['productId'] = res.group(2).lstrip().rstrip()
deviceDict[keyString]['productName'] = res.group(3).lstrip().rstrip()
- #find the class
- if crow.find('bInterfaceClass') != -1:
- #print crow
- res = re.match('bInterfaceClass([\s]*)([0-9]*)(.*)',crow,re.I)
- if res:
- deviceDict[keyString]['classId'] = self.addLeadingZero(res.group(2).lstrip().rstrip())
- deviceDict[keyString]['className'] = res.group(3).lstrip().rstrip()
-
- #find the subclass
- if crow.find('bInterfaceSubClass') != -1:
- #print crow
- res = re.match('bInterfaceSubClass([\s]*)([0-9]*)(.*)',crow,re.I)
- if res:
- deviceDict[keyString]['subclassId'] = self.addLeadingZero(res.group(2).lstrip().rstrip())
- deviceDict[keyString]['subclassName'] = res.group(3).lstrip().rstrip()
-
- #find the protocol
- if crow.find('bInterfaceProtocol') != -1:
- #print crow
- res = re.match('bInterfaceProtocol([\s]*)([0-9]*)(.*)',crow,re.I)
- if res:
- deviceDict[keyString]['protocolId'] = self.addLeadingZero(res.group(2).lstrip().rstrip())
- deviceDict[keyString]['protocolName'] = res.group(3).lstrip().rstrip()
-
+ if usbDeviceIsFound == 'N':
+ #find the class
+ if crow.find('bInterfaceClass') != -1:
+ #print crow
+ res = re.match('bInterfaceClass([\s]*)([0-9]*)(.*)',crow,re.I)
+ if res:
+ cl = hex(int(res.group(2).lstrip().rstrip()))
+ deviceDict[keyString]['classId'] = self.addLeadingZero(cl[2:])
+ deviceDict[keyString]['className'] = res.group(3).lstrip().rstrip()
+
+ #find the subclass
+ if crow.find('bInterfaceSubClass') != -1:
+ #print crow
+ res = re.match('bInterfaceSubClass([\s]*)([0-9]*)(.*)',crow,re.I)
+ if res:
+ cl = hex(int(res.group(2).lstrip().rstrip()))
+ deviceDict[keyString]['subclassId'] = self.addLeadingZero(cl[2:])
+ deviceDict[keyString]['subclassName'] = res.group(3).lstrip().rstrip()
+
+ #find the protocol
+ if crow.find('bInterfaceProtocol') != -1:
+ #print crow
+ res = re.match('bInterfaceProtocol([\s]*)([0-9]*)(.*)',crow,re.I)
+ if res:
+ cl = hex(int(res.group(2).lstrip().rstrip()))
+ deviceDict[keyString]['protocolId'] = self.addLeadingZero(cl[2:])
+ deviceDict[keyString]['protocolName'] = res.group(3).lstrip().rstrip()
+
+ currentClassCode = str(deviceDict[keyString]['classId'])+str(deviceDict[keyString]['subclassId'])+str(deviceDict[keyString]['protocolId'])
+
+ if self.getObject(currentClassCode) and currentClassCode != 'ffffff':
+ usbDeviceIsFound = 'Y'
f.close();
#create the USB devices
for key,value in deviceDict.iteritems():
Class = str(value['classId']) + str(value['subclassId']) + str(value['protocolId'])
+
#get the USB object
dev = self.getObject(Class)
if dev:
dev.setType(self.getType(Class))
dev.setVendorId(value['vendorId'])
+ dev.setInterface('USB')
dev.setProductId(value['productId'])
dev.setModel(value['productName'])