]> gitweb.pimeys.fr Git - NK2015_Client_Python_Alpha.git/commitdiff
Un peu de getpass et de secrets
authorVincent Le Gallic <legallic@crans.org>
Sun, 1 Mar 2015 18:16:05 +0000 (19:16 +0100)
committerVincent Le Gallic <legallic@crans.org>
Sun, 1 Mar 2015 18:16:05 +0000 (19:16 +0100)
.gitignore
client.py

index f970c328db816d879fc3a723276d12601f14ad5f..67f8f0470e19bf2115d5879e90f4bbef5d96889c 100644 (file)
@@ -1,6 +1,7 @@
 # Custom #
 ###################
 *~
+secrets.py
 
 # Compiled source #
 ###################
index 6f5d83ed194d930084cd32ccadae123cb54d77c8..82a6071c7a501cf3b60736b805dcc58dcf0bb3e8 100755 (executable)
--- 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\""