aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--h-client/hlibrary.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 8e3dd89..4ec7bef 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -90,16 +90,25 @@ class Device(object):
return self._distrosTable[codename]
return ''
- #add a distribution to the comma-separated list of distros
+ #add a distribution
def addDistribution(self,distroName):
distros = self._distributions.split(',')
- distros.append(distroName)
+ distros.append(distroName.lstrip().rstrip())
+
#remove duplicates
- distros = list(set(distros))
- self._distributions = ','.join(distros)
+ #distros = list(set(distros))
+
+ self._distributions = ' , '.join(distros)
#correct a strange behaviour
- if self._distributions[0] == ',':
- self._distributions = self._distributions[1:]
+ if self._distributions[0] == ' , ':
+ self._distributions = self._distributions[3:]
+
+ #add many distributions
+ #distroList: comma separated list of distros
+ def addDistributions(self,distroList):
+ distros = distroList.split(',')
+ for distro in distros:
+ self.addDistribution(distro)
def userDistribution(self):
if not os.system('cat /etc/*-release | grep CODENAME > tmp/temp'):
@@ -434,21 +443,21 @@ class Client:
if code.hasChildNodes():
if (code.childNodes[0].data == vendorid_productid):
- modelName = device.getElementsByTagName("model_name")[0].childNodes[0].data
- interface = device.getElementsByTagName("interface")[0].childNodes[0].data
- distribution = device.getElementsByTagName("distribution")[0].childNodes[0].data
- idDevice = device.getElementsByTagName("id")[0].childNodes[0].data
- works = device.getElementsByTagName("it_works")[0].childNodes[0].data
- year = device.getElementsByTagName("year")[0].childNodes[0].data
+ 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')
+ idDevice = device.getElementsByTagName("id")[0].childNodes[0].data.encode('utf-8')
+ works = device.getElementsByTagName("it_works")[0].childNodes[0].data.encode('utf-8')
+ year = device.getElementsByTagName("year")[0].childNodes[0].data.encode('utf-8')
if device.getElementsByTagName("description")[0].hasChildNodes():
- description = device.getElementsByTagName("description")[0].childNodes[0].data
+ description = device.getElementsByTagName("description")[0].childNodes[0].data.encode('utf-8')
dev[0].setDescription(description)
#print modelName
dev[0].setModel(modelName)
dev[0].setInterface(interface)
- dev[0].setDistributions(distribution)
+ dev[0].addDistributions(distribution)
dev[0].setHowItWorks(works)
dev[0].setYear(year)
dev[2] = 'update'