def hello(socket,version):
socket.send('hello "%s"'%(version))
- return json.loads(a.read())
+ return lit(a)
def login(socket,user,mdp="",typ="bdd"):
if user in ["20-100","moibdd"]:
a.write('login ["vincent","mdp","special"]')
else:
a.write('login ["%s","%s","%s"]'%(user,mdp,typ))
- return json.loads(a.read())
+ return lit(a)
def search(socket,term):
a.write("search %s"%(term))
return json.loads(a.read())
-def lit(socket,noprint=False):
+def lit(socket):
try:
t=a.read()
- if noprint:
- return json.loads(t)
+ obj=json.loads(t)
+ if obj["retcode"]==0:
+ return obj['msg']
else:
- obj=json.loads(t)
- if type(obj)==unicode:
- print obj
- else:
- pprint(obj)
+ print obj["errmsg"]
+ return obj["msg"]
except ssl.SSLError:
- print "Rien à lire"
+ return "Rien à lire"
except ValueError:
- print "Serveur mort ?"
+ return "Serveur mort ?"
def challenge(a):
_,pub=monRSA.litcles(None,client_config.server_rsa_pub_key)