From f32b61c7c4f499b9393524fc7ae9bbfc05b9b729 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sun, 1 May 2011 10:35:49 +0000 Subject: h-client:USB printers can now be submitted by means of the client --- h-client/hclient.py | 57 ++++++++++++++++++++++++++++++++++++++++------------ h-client/hlibrary.py | 19 ++++++++++++++++++ 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/h-client/hclient.py b/h-client/hclient.py index ab15ce2..2cd8d5c 100644 --- a/h-client/hclient.py +++ b/h-client/hclient.py @@ -43,6 +43,8 @@ class hclient: def applyChanges(self,widget): self.currentDevice.setModel(self.modelNameEntry.get_text()) + self.currentDevice.setSubtype(self.getActive(self.subtypeCombo)) + self.currentDevice.setYear(self.getActive(self.commYearCombo)) self.currentDevice.setInterface(self.getActive(self.interfaceCombo)) @@ -118,6 +120,8 @@ class hclient: self.setModelEntry() #set the vendorid:productid entry self.setVendorIdProductIDCode() + #set the subtype entry (in the case of printers) + self.setSubtypeEntry() #set the commercialization year entry self.setCommYearEntry() #set the interface entry @@ -144,6 +148,20 @@ class hclient: self.vendorIdProductIdEntry.set_text(self.currentDevice.getVendorId() + ':' + self.currentDevice.getProductId()) + #set the subtype entry (in the case pf printers) + def setSubtypeEntry(self): + self.subtypeCombo.get_model().clear() + for subtype in self.currentDevice.getSubtypes(): + self.subtypeCombo.append_text(subtype) + + if self.currentDevice.getSubtype() in self.currentDevice.getSubtypes(): + index = self.currentDevice.getSubtypes().index(self.currentDevice.getSubtype()) + else: + index = 0 + + self.subtypeCombo.set_active(index) + + #set the year of commercialization def setCommYearEntry(self): self.commYearCombo.get_model().clear() @@ -756,7 +774,7 @@ class hclient: #add the input to the table self.rightTable.attach(self.modelNameEntry, 1, 2, 0, 1) - + ### vendorid:productid #vendorid:productid label self.vendorIdProductIdLabel = gtk.Label("VendorID:productID code:") @@ -772,17 +790,30 @@ class hclient: self.rightTable.attach(self.vendorIdProductIdEntry, 1, 2, 1, 2) + ###subtype + #subtype label + self.subtypeLabel = gtk.Label("Subtype:") + self.subtypeLabel.set_alignment(0.95,0.5) + #add the label + self.rightTable.attach(self.subtypeLabel, 0, 1, 2, 3) + + #subtype input + self.subtypeCombo = gtk.combo_box_new_text() + #add the input to the table + self.rightTable.attach(self.subtypeCombo, 1, 2, 2, 3) + + ###year of commercialization #year of commercialization label self.commYearLabel = gtk.Label("Year of commercialization:") self.commYearLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.commYearLabel, 0, 1, 2, 3) + self.rightTable.attach(self.commYearLabel, 0, 1, 3, 4) self.commYearCombo = gtk.combo_box_new_text() #add the combo to the table - self.rightTable.attach(self.commYearCombo, 1, 2, 2, 3) + self.rightTable.attach(self.commYearCombo, 1, 2, 3, 4) ###interface @@ -790,7 +821,7 @@ class hclient: self.interfaceLabel = gtk.Label("Interface:") self.interfaceLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.interfaceLabel, 0, 1, 3, 4) + self.rightTable.attach(self.interfaceLabel, 0, 1, 4, 5) self.interfaceCombo = gtk.combo_box_new_text() @@ -799,7 +830,7 @@ class hclient: self.interfaceCombo.set_active(0) #add the combo to the table - self.rightTable.attach(self.interfaceCombo, 1, 2, 3, 4) + self.rightTable.attach(self.interfaceCombo, 1, 2, 4, 5) ### distribution @@ -807,7 +838,7 @@ class hclient: self.distributionLabel = gtk.Label("Distribution used: ") self.distributionLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.distributionLabel, 0, 1, 4, 5) + self.rightTable.attach(self.distributionLabel, 0, 1, 5, 6) #distribution input self.distributionEntry = gtk.Entry() @@ -815,7 +846,7 @@ class hclient: #add the input - self.rightTable.attach(self.distributionEntry, 1, 2, 4, 5) + self.rightTable.attach(self.distributionEntry, 1, 2, 5, 6) ### kernel @@ -823,12 +854,12 @@ class hclient: self.kernelLabel = gtk.Label("Kernel libre version:") self.kernelLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.kernelLabel, 0, 1, 5, 6) + self.rightTable.attach(self.kernelLabel, 0, 1, 6, 7) #kernel input self.kernelEntry = gtk.Entry() #add the input - self.rightTable.attach(self.kernelEntry, 1, 2, 5, 6) + self.rightTable.attach(self.kernelEntry, 1, 2, 6, 7) ###how it works @@ -836,12 +867,12 @@ class hclient: self.howItWorksLabel = gtk.Label("Does it work?") self.howItWorksLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.howItWorksLabel, 0, 1, 6, 7) + self.rightTable.attach(self.howItWorksLabel, 0, 1, 7, 8) self.howItWorksCombo = gtk.combo_box_new_text() #add the combo to the table - self.rightTable.attach(self.howItWorksCombo, 1, 2, 6, 7) + self.rightTable.attach(self.howItWorksCombo, 1, 2, 7, 8) ### driver @@ -849,12 +880,12 @@ class hclient: self.driverLabel = gtk.Label("Free driver used:") self.driverLabel.set_alignment(0.95,0.5) #add the label - self.rightTable.attach(self.driverLabel, 0, 1, 7, 8) + self.rightTable.attach(self.driverLabel, 0, 1, 8, 9) #driver input self.driverEntry = gtk.Entry() #add the input - self.rightTable.attach(self.driverEntry, 1, 2, 7, 8) + self.rightTable.attach(self.driverEntry, 1, 2, 8, 9) ### description diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py index 7523e35..83ca3a9 100644 --- a/h-client/hlibrary.py +++ b/h-client/hlibrary.py @@ -42,6 +42,9 @@ class Device(object): #list of options for the howItWorks entry _howItWorksOptions = ['yes','no'] + #list of subtypes + _subtypes = [] + #allowed years of commercialization _years = [ 'not-specified', @@ -88,6 +91,7 @@ class Device(object): self._howItWorks = '' self._driver = '' self._description = '' + self._subtype = 'not-specified' self._icon = 'unknown.png' def setPost(self): @@ -154,6 +158,12 @@ class Device(object): self._status = False self.errors.append('tmp folder not writable') + def getSubtype(self): + return self._subtype + + def getSubtypes(self): + return self._subtypes + def getHowItWorksOptions(self): return self._howItWorksOptions @@ -238,6 +248,9 @@ class Device(object): def setDescription(self,description): self._description = description + def setSubtype(self,subtype): + self._subtype = subtype + def getStatus(self): return self._status @@ -292,11 +305,13 @@ class Printer(Device): self._howItWorks = 'C-None' self._interfaces = ['not-specified','USB','Serial','Parallel','Firewire','SCSI','Ethernet'] self._howItWorksOptions = ['A-Full','B-Partial','C-None'] + self._subtypes = ['not-specified','laser','inkjet','other'] self._icon = 'printer.png' def setPost(self): super(Printer, self).setPost() self._post['compatibility'] = self._howItWorks + self._post['subtype'] = self._subtype #class to carry out http requests by means of pycurl class Mycurl: @@ -726,6 +741,10 @@ class Client: if deviceType == 'printer': works = device.getElementsByTagName("compatibility")[0].childNodes[0].data.encode('utf-8') + + #set the subtype + subtype = device.getElementsByTagName("subtype")[0].childNodes[0].data.encode('utf-8') + dev[0].setSubtype(subtype) else: works = device.getElementsByTagName("it_works")[0].childNodes[0].data.encode('utf-8') -- cgit v1.2.3