diff options
Diffstat (limited to 'h-client')
-rw-r--r-- | h-client/hclient.py | 36 | ||||
-rw-r--r-- | h-client/hlibrary.py | 15 |
2 files changed, 39 insertions, 12 deletions
diff --git a/h-client/hclient.py b/h-client/hclient.py index 709165a..e8783b8 100644 --- a/h-client/hclient.py +++ b/h-client/hclient.py @@ -25,7 +25,7 @@ from hlibrary import * class hclient: #the device that has to be displaced in the right window - currentDevice = '' + currentDevice = None #get the active text from a combo #combo: the gtk combo instance @@ -88,7 +88,9 @@ class hclient: self.resetButton.set_sensitive(True) else: - + #make non sensitive the apply button + self.applyButton.set_sensitive(False) + self.resetButton.set_sensitive(False) self.currentDevice = None @@ -237,13 +239,31 @@ class hclient: self.prefWindow.show_all() - + #synchronize with the server XML database def synchronize(self,widget): self.client.sync() - print self.client.errors + self.printErrors() + #print self.client.errors self.setEntries() - + + def printErrors(self): + if len(self.client.errors) > 0: + sw = gtk.ScrolledWindow() + #sw.set_shadow_type(gtk.SHADOW_ETCHED_IN) + sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER) + hbox = gtk.HBox(False, 0) + for error in self.client.errors: + label = gtk.Label("error: " + error) + hbox.pack_start(label, False, True, 0) + + sw.add_with_viewport(hbox) + sw.set_border_width(5) + sw.show_all() + self.bottomWindow.add(sw) + + self.client.errors = [] + #another callback def delete_event(self, widget, event, data=None): gtk.main_quit() @@ -273,7 +293,8 @@ class hclient: self.window.add(vbox) self.centerWindow = gtk.HBox(False, 0) - + self.bottomWindow = gtk.HBox(False, 0) + ## build the toolbar ## toolbar = gtk.Toolbar() toolbar.set_tooltips(True) @@ -297,6 +318,7 @@ class hclient: vbox.pack_start(self.centerWindow, True, True, 0) + vbox.pack_start(self.bottomWindow, True, True, 0) vbox.show() @@ -523,7 +545,7 @@ class hclient: #self.rframe.set_border_width(30) self.centerWindow.show_all() - + self.bottomWindow.show_all() self.leftWindow.show() self.window.show() diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py index 415b04b..3205fbd 100644 --- a/h-client/hlibrary.py +++ b/h-client/hlibrary.py @@ -337,11 +337,16 @@ class Mycurl: c.setopt(c.POSTFIELDS, urllib.urlencode(self._post)) c.setopt(c.WRITEFUNCTION, self.body_callback) - c.perform() - - result = False - if c.getinfo(c.HTTP_CODE) == 200: + try: + c.perform() result = True + except: + result = False + + #print c.getinfo(c.HTTP_CODE) + #result = False + #if c.getinfo(c.HTTP_CODE) == 200: + #result = True c.close() return result @@ -573,7 +578,7 @@ class Client: dev[3] = idDevice else: self._status = False - self.errors.append("couldn't connect to host") + self.errors.append("unable to connect to server") def submit(self): for key,dev in self.devices.iteritems(): |