From 0234c46244689bd864dcadb93844612b413ed1f8 Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sat, 2 Apr 2011 16:38:59 +0000 Subject: h-client: improved the way errors are shown --- h-client/hlibrary.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'h-client/hlibrary.py') diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py index 79679b7..ae27316 100644 --- a/h-client/hlibrary.py +++ b/h-client/hlibrary.py @@ -421,8 +421,18 @@ class Client: #log in def login(self, username, password): self.request.setPost({'username' : username, 'password' : password}) - self.request.perform('users/login/en') + result = self.request.perform('users/login/en') self.request.setPost(None) + if result: + if self.isLogged(): + return True + else: + self.errors.append("wrong username or password") + else: + self.errors.append("unable to connect to server") + return -1 + + return False #log out def logout(self): @@ -450,13 +460,13 @@ class Client: else: self._status = False self.errors.append("unable to connect to server") - return False + return -1 #return True if the user is logged, else return False def isLogged(self): info = self.getUserInfo() - if info != False: + if info != -1: if info['status'] == 'logged': return True -- cgit v1.2.3