diff options
author | Antonio Gallo <tonicucoz@gmail.com> | 2011-03-15 14:00:54 +0000 |
---|---|---|
committer | Antonio Gallo <tonicucoz@gmail.com> | 2011-03-15 14:00:54 +0000 |
commit | d6272a60687f2e62218e036eb05fb127301d3a27 (patch) | |
tree | 8d89a228a788b4264598242afbb9d26fecadb2a5 /h-client | |
parent | 5d9649f5af2d7d30c86d6fb0698090b2500c29be (diff) |
improved the way distribution are retrieved
Diffstat (limited to 'h-client')
-rw-r--r-- | h-client/hlibrary.py | 37 |
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' |