From d305b74c85f3460df754b724bd71d6eebb15c587 Mon Sep 17 00:00:00 2001 From: Vincent Le Gallic Date: Sun, 1 Mar 2015 19:16:05 +0100 Subject: [PATCH] Un peu de getpass et de secrets --- .gitignore | 1 + client.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f970c32..67f8f04 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Custom # ################### *~ +secrets.py # Compiled source # ################### diff --git a/client.py b/client.py index 6f5d83e..82a6071 100755 --- a/client.py +++ b/client.py @@ -72,7 +72,7 @@ def hello(socket,version): return lit(a) def login(socket,user,mdp="",typ="bdd"): - if user in ["20-100","moibdd","#1"]: + if user in ["#1", "test"]: a.write('["login", ["#1","plop","bdd",[[],[],false]]]') elif user in ["vincent","moi"]: a.write('["login", ["vincent","plop","special",[]]]') @@ -80,6 +80,9 @@ def login(socket,user,mdp="",typ="bdd"): a.write('["login", ["toto","plop","bdd",[[],[],false]]]') else: a.write('["login", ["%s","%s","%s",[[],[],false]]]'%(user,mdp,typ)) + if mdp == "": + import getpass + mdp = getpass.getpass() return lit(a) def search(socket,term): @@ -110,6 +113,13 @@ if __name__=="__main__": a.settimeout(2) #checkidentity(a) print hello(a,"Python Client alpha") + try: + import secrets + user = secrets.user + password = secrets.password + except ImportError: + print "Y U no secrets.py !?" + exit(1) print login(a,"20-100","plop") print "Socket créée dans la variable \"a\"" -- 2.39.2