aboutsummaryrefslogtreecommitdiff
path: root/h-client/hlibrary.py
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-04-01 22:47:24 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-04-01 22:47:24 +0000
commit24349e9580e1b22f5f114c5af91cbf534aaf47af (patch)
treeee33fed1231e97f25225e012ceeec14aa82e62e5 /h-client/hlibrary.py
parent2444b6adb8cf240c6a024d661ee6d2756c66f1c6 (diff)
h-client:implemented login - requested svn version of h-source
Diffstat (limited to 'h-client/hlibrary.py')
-rw-r--r--h-client/hlibrary.py40
1 files changed, 24 insertions, 16 deletions
diff --git a/h-client/hlibrary.py b/h-client/hlibrary.py
index 3205fbd..79679b7 100644
--- a/h-client/hlibrary.py
+++ b/h-client/hlibrary.py
@@ -373,7 +373,7 @@ class Client:
}
}
- def __init__(self,url = 'http://www.h-node.com'):
+ def __init__(self,url = ''):
self.request = Mycurl(url)
def getNode(self):
@@ -430,27 +430,35 @@ class Client:
#get info about the user logged
def getUserInfo(self):
- self.request.perform('users/info/en')
- xmldoc = minidom.parseString(self.request.contents)
- status = xmldoc.getElementsByTagName("status")[0].childNodes[0].data
-
- username = ''
- token = ''
- groups = ''
-
- if status == 'logged':
- username = xmldoc.getElementsByTagName("username")[0].childNodes[0].data
- token = xmldoc.getElementsByTagName("token")[0].childNodes[0].data
- groups = xmldoc.getElementsByTagName("groups")[0].childNodes[0].data
+ result = self.request.perform('users/info/en')
+
+ if result:
+ xmldoc = minidom.parseString(self.request.contents)
+ status = xmldoc.getElementsByTagName("status")[0].childNodes[0].data
+
+ username = ''
+ token = ''
+ groups = ''
+
+ if status == 'logged':
+ username = xmldoc.getElementsByTagName("username")[0].childNodes[0].data
+ token = xmldoc.getElementsByTagName("token")[0].childNodes[0].data
+ groups = xmldoc.getElementsByTagName("groups")[0].childNodes[0].data
+
+ return {'status':status,'username':username,'token':token,'groups':groups}
- return {'status':status,'username':username,'token':token,'groups':groups}
+ else:
+ self._status = False
+ self.errors.append("unable to connect to server")
+ return False
#return True if the user is logged, else return False
def isLogged(self):
info = self.getUserInfo()
- if info['status'] == 'logged':
- return True
+ if info != False:
+ if info['status'] == 'logged':
+ return True
return False