aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--h-client/hclient.py4
-rw-r--r--h-client/hlibrary.py80
-rw-r--r--h-client/test.py27
3 files changed, 103 insertions, 8 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py
index 3d8af58..57a5cbd 100644
--- a/h-client/hclient.py
+++ b/h-client/hclient.py
@@ -503,14 +503,14 @@ class hclient:
table.attach(self.passwordEntry, 1, 2, 1, 2)
### create new account
- label = gtk.Label("<a href='http://"+self.client.getNode()+"/users/add/en'>Create new account</a>")
+ label = gtk.Label("<a href='http://"+self.client.getNode()+"users/add/en'>Create new account</a>")
label.set_use_markup(True)
label.set_alignment(0.98,0.5)
#add the label
table.attach(label, 0, 2, 2, 3)
### request new password
- label = gtk.Label("<a href='http://"+self.client.getNode()+"/users/forgot/en'>Request new password</a>")
+ label = gtk.Label("<a href='http://"+self.client.getNode()+"users/forgot/en'>Request new password</a>")
label.set_use_markup(True)
label.set_alignment(0.98,0.5)
#add the label
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')
diff --git a/h-client/test.py b/h-client/test.py
index 9fef89c..c09d6a2 100644
--- a/h-client/test.py
+++ b/h-client/test.py
@@ -32,15 +32,34 @@ client.createDevices()
#print dev[0].getYear()
#print dev[3]
#print dev[0].getHowItWorks()
- #print dev[0].getDescription()+"\n"+"\n"
+ #print dev[0].getDescription()
+ #print dev[0].getIcon()
+ ##dev[0].addDistribution('taranis')
+ ##dev[0].addDistribution('metad')
+ ##dev[0].addDistribution('gingo')
+ ##dev[0].addDistribution('taranis')
+ #print dev[0].getDistributions()
+ ##print dev[0].userDistribution()
+
+client.changeType('u_0846:4260','wifi')
+
+
+for key,dev in client.devices.iteritems():
+ print key
+ print dev[0].getModel()
+ print dev[0].getType()
+ print dev[0].getDistributions()
+ print dev[0].getYear()
+ print dev[3]
+ print dev[0].getHowItWorks()
+ print dev[0].getDescription()
+ print dev[0].getIcon()
#dev[0].addDistribution('taranis')
#dev[0].addDistribution('metad')
#dev[0].addDistribution('gingo')
#dev[0].addDistribution('taranis')
- #print dev[0].getDistributions()
+ print dev[0].getDistributions()
#print dev[0].userDistribution()
-
-
#client.login('','')
##print client.isLogged()
#client.submit()