[server/utils] convert to py3k using six
authorRémi Cardona <remi.cardona@logilab.fr>
Tue, 15 Sep 2015 17:31:07 +0200
changeset 10678 77333ec71fab
parent 10677 59ec0aaae08b
child 10679 76bb963c7e8e
[server/utils] convert to py3k using six
server/utils.py
--- a/server/utils.py	Tue Sep 15 17:28:05 2015 +0200
+++ b/server/utils.py	Tue Sep 15 17:31:07 2015 +0200
@@ -25,6 +25,9 @@
 from threading import Timer, Thread
 from getpass import getpass
 
+from six import PY2, text_type
+from six.moves import input
+
 from passlib.utils import handlers as uh, to_hash_str
 from passlib.context import CryptContext
 
@@ -82,7 +85,7 @@
     if eschema.eid is None:
         eschema.eid = cnx.execute(
             'Any X WHERE X is CWEType, X name %(name)s',
-            {'name': unicode(eschema)})[0][0]
+            {'name': text_type(eschema)})[0][0]
     return eschema.eid
 
 
@@ -95,8 +98,9 @@
         if msg:
             print(msg)
         while not user:
-            user = raw_input('login: ')
-        user = unicode(user, sys.stdin.encoding)
+            user = input('login: ')
+        if PY2:
+            user = unicode(user, sys.stdin.encoding)
     passwd = getpass('%s: ' % passwdmsg)
     if confirm:
         while True: