aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--h-client/hlibrary.py71
-rw-r--r--h-client/test.py49
2 files changed, 71 insertions, 49 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 4ec7bef..1a86d81 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -29,6 +29,8 @@ from xml.dom import minidom
class Device(object):
_distrosTable = {
+ 'deltah' : 'gnewsense_2_3',
+ 'metad' : 'gnewsense_3_0',
'awen' : 'trisquel_3_5',
'taranis' : 'trisquel_4_0',
'slaine' : 'trisquel_4_5'
@@ -62,7 +64,7 @@ class Device(object):
self._vendor = None
self._model = None
self._kernel = None
- self._distributions = self.userDistribution()
+ self._distributions = [self.userDistribution()]
self._interface = 'not-specified'
self._year = 'not-specified'
self._vendorId = None
@@ -74,7 +76,7 @@ class Device(object):
def setPost(self):
self._post['model'] = self._model;
self._post['kernel'] = self._kernel;
- self._post['distribution'] = self._distributions;
+ self._post['distribution'] = self.createDistroEntry();
self._post['comm_year'] = self._year;
self._post['pci_id'] = self._vendorId + ':' + self._productId;
self._post['interface'] = self._interface;
@@ -90,18 +92,25 @@ class Device(object):
return self._distrosTable[codename]
return ''
- #add a distribution
- def addDistribution(self,distroName):
- distros = self._distributions.split(',')
- distros.append(distroName.lstrip().rstrip())
+ def createDistroEntry(self):
+ cleanDistros = []
+ for distro in self._distributions:
+ cleanDistros.append(distro.lstrip().rstrip())
#remove duplicates
- #distros = list(set(distros))
-
- self._distributions = ' , '.join(distros)
- #correct a strange behaviour
- if self._distributions[0] == ' , ':
- self._distributions = self._distributions[3:]
+ cleanDistros = list(set(cleanDistros))
+ #sort the elements
+ cleanDistros = sorted(cleanDistros)
+
+ dis = ' , '.join(cleanDistros)
+ #correct a strange python behaviour
+ if dis[0] == ' , ':
+ dis = dis[3:]
+ return dis
+
+ #add a distribution
+ def addDistribution(self,distroName):
+ self._distributions.append(distroName)
#add many distributions
#distroList: comma separated list of distros
@@ -488,40 +497,4 @@ class Client:
self.request.setPost(post)
self.request.perform(url.encode('utf-8'))
- #print self.request.contents
-
-#d = Videocard()
-
-#d.setVendor('Acer')
-#print d.getType()
-#d.setDistributions('trisquel_4_0,gnewsense');
-#print d.getStatus()
-
-client = Client('http://h-source/')
-client.createDevices()
-#client.request.perform('download/all/it')
-#print client.request.url
-client.sync()
-
-#for key,dev in client.devices.iteritems():
- #print key
- #print dev[0].getModel()
- #print dev[0].getDistributions()
- #print dev[0].getYear()
- #print dev[3]
- #print dev[0].getHowItWorks()
- #print dev[0].getDescription()+"\n"+"\n"
- #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.login('','')
-#print client.isLogged()
-client.submit()
-client.logout()
-#client.devices['p_14e4:4311'][0].setPost()
-#print client.devices['p_14e4:4311'][0].getPost() \ No newline at end of file
+ #print self.request.contents \ No newline at end of file
diff --git a/h-client/test.py b/h-client/test.py
new file mode 100644
index 0000000..ca13ee7
--- /dev/null
+++ b/h-client/test.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+# hlibrary, a python library to manage the database of an h-source node
+# Copyright (C) 2011 Antonio Gallo
+#
+#
+# hlibrary is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# hlibrary is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with hlibrary. If not, see <http://www.gnu.org/licenses/>.
+
+from hlibrary import *
+
+client = Client('http://h-source/')
+client.createDevices()
+#client.request.perform('download/all/it')
+#print client.request.url
+client.sync()
+
+#for key,dev in client.devices.iteritems():
+ #print key
+ #print dev[0].getModel()
+ #print dev[0].getDistributions()
+ #print dev[0].getYear()
+ #print dev[3]
+ #print dev[0].getHowItWorks()
+ #print dev[0].getDescription()+"\n"+"\n"
+ #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.login('','')
+#print client.isLogged()
+client.submit()
+client.logout()
+
+#client.devices['p_14e4:4311'][0].setPost()
+#print client.devices['p_14e4:4311'][0].getPost() \ No newline at end of file