Add support to console's input to nullclient.py
authorRagner Magalhaes <ragner.magalhaes@openbossa.org>
Tue, 2 Dec 2008 20:17:50 +0000 (20:17 +0000)
committerAnderson Briglia <anderson.briglia@openbossa.org>
Sat, 28 Feb 2009 21:11:09 +0000 (17:11 -0400)
Allow user input name and password to nullclient.py

Signed-off-by: Ragner Magalhaes <ragner.magalhaes@indt.org.br>

git-svn-id: https://garage.maemo.org/svn/carman/branches/carman-0.7-beta2/python-purple@1291 596f6dd7-e928-0410-a184-9e12fd12cf7e

nullclient.py

index 93fd270..c9e1953 100644 (file)
@@ -1,5 +1,7 @@
 import purple
 import ecore
 import purple
 import ecore
+import getpass
+import sys
 
 class NullClient:
     def __init__(self):
 
 class NullClient:
     def __init__(self):
@@ -22,12 +24,22 @@ class NullClient:
         self.account.set_password(password)
         self.account.set_enabled("carman-purple-python", True)
 
         self.account.set_password(password)
         self.account.set_enabled("carman-purple-python", True)
 
+def getuser():
+    sys.stdout.write("GTalk account: ")
+    username = sys.stdin.readline()
+    return username[:-1]
+
+def getpassword():
+    return getpass.getpass()
+
 if __name__ == '__main__':
 
     client = NullClient()
     client.execute()
     client.set_protocol("XMPP")
 if __name__ == '__main__':
 
     client = NullClient()
     client.execute()
     client.set_protocol("XMPP")
-    client.new_account("seu_email@email.com", client.protocol,"sua_senha_aqui")
+    username = getuser()
+    password = getpassword()
+    client.new_account(username, client.protocol, password)
 
     client.p.connect()
     ecore.main_loop_begin()
 
     client.p.connect()
     ecore.main_loop_begin()