aboutsummaryrefslogtreecommitdiff
path: root/h-client/hlibrary.py
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-05-26 14:15:16 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-05-26 14:15:16 +0000
commit608eec28eb559dbfd20fe732a506219a09682cbc (patch)
treefd508c56a12ff1840e293b42e585151cd0fb9dac /h-client/hlibrary.py
parentb10b6c09d4085f6939140cb64f0f61aeeb653eca (diff)
h-client:the type of each device can be now updated during the synchronize process
Diffstat (limited to 'h-client/hlibrary.py')
-rw-r--r--h-client/hlibrary.py80
1 files changed, 78 insertions, 2 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index e855d46..e8b577b 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -261,6 +261,9 @@ class Device(object):
def setSubtype(self,subtype):
self._subtype = subtype
+ def setIcon(self,icon):
+ self._icon = icon
+
def getStatus(self):
return self._status
@@ -527,6 +530,14 @@ class Client:
'type' : 'webcam',
'controller': 'webcams'
},
+ '060101' : {
+ 'type' : 'scanner',
+ 'controller': 'scanners'
+ },
+ '0d0000' : {
+ 'type' : 'fingerprint-reader',
+ 'controller': 'fingerprintreaders'
+ },
'ffffff' : {
'type' : 'unknown',
'controller': 'unknown'
@@ -534,6 +545,7 @@ class Client:
}
def __init__(self,url = ''):
+
self.request = Mycurl(url)
#create the allowedDistros ordered dictionary
@@ -598,12 +610,46 @@ class Client:
return Webcam()
elif Class == 'e00101':
return Bluetooth()
+ elif Class == '060101':
+ return Scanner()
+ elif Class == '0d0000':
+ return Fingerprintreader()
+ elif Class == '020205':
+ return Threegcard()
elif Class == 'ffffff':
return Unknown()
else:
return None
- #get the system kernel
+ def getObjectFromType(self,Type):
+ if Type == 'soundcard':
+ return Soundcard()
+ elif Type == 'wifi':
+ return Wifi()
+ elif Type == 'videocard':
+ return Videocard()
+ elif Type == 'printer':
+ return Printer()
+ elif Type == 'webcam':
+ return Webcam()
+ elif Type == 'bluetooth':
+ return Bluetooth()
+ elif Type == 'scanner':
+ return Scanner()
+ elif Type == 'fingerprint-reader':
+ return Fingerprintreader()
+ elif Type == '3G-card':
+ return Threegcard()
+ else:
+ return None
+
+ #get the class from the type
+ def getClassFromType(self,Type):
+ for Class,struct in self._types.iteritems():
+ if struct['type'] == Type:
+ return Class
+
+ #get the kernel version
def getKernel(self):
if not os.system('uname -r > tmp/kernel'):
f = open('tmp/kernel','r')
@@ -842,6 +888,32 @@ class Client:
else:
self.errors.append('tmp folder not writable')
+ #change the type of a device
+ #deviceCode: the code of the device
+ #nType: the new type of the device
+ def changeType(self,deviceCode,nType):
+ dev = self.getObjectFromType(nType)
+
+ if dev != None:
+ dev.setModel(self.devices[deviceCode][0].getModel())
+ dev.setOtherNames(self.devices[deviceCode][0].getOtherNames())
+ dev.setKernel(self.devices[deviceCode][0].getKernel())
+ dev.setDistributions(self.devices[deviceCode][0].getDistributions())
+ dev.setInterface(self.devices[deviceCode][0].getInterface())
+ dev.setYear(self.devices[deviceCode][0].getYear())
+ dev.setVendorId(self.devices[deviceCode][0].getVendorId())
+ dev.setProductId(self.devices[deviceCode][0].getProductId())
+ dev.setHowItWorks(self.devices[deviceCode][0].getHowItWorks())
+ dev.setDriver(self.devices[deviceCode][0].getDriver())
+ dev.setDescription(self.devices[deviceCode][0].getDescription())
+ dev.setSubtype(self.devices[deviceCode][0].getSubtype())
+ dev.setIcon(nType+".png")
+
+ Class = self.getClassFromType(nType)
+ self.devices[deviceCode][0] = dev
+ self.devices[deviceCode][1] = Class
+
+
#syncronize with the xml database
def sync(self):
@@ -874,7 +946,11 @@ class Client:
if deviceType != 'notebook':
code = device.getElementsByTagName("vendorid_productid")[0]
if code.hasChildNodes():
- if (code.childNodes[0].data == vendorid_productid):
+ if code.childNodes[0].data == vendorid_productid:
+
+ if deviceType != dev[0].getType():
+ self.changeType(key,deviceType)
+
modelName = device.getElementsByTagName("model_name")[0].childNodes[0].data.encode('utf-8')
interface = device.getElementsByTagName("interface")[0].childNodes[0].data.encode('utf-8')
distribution = device.getElementsByTagName("distribution")[0].childNodes[0].data.encode('utf-8')