equal
deleted
inserted
replaced
22 |
22 |
23 import sys |
23 import sys |
24 import logging |
24 import logging |
25 from threading import Timer, Thread |
25 from threading import Timer, Thread |
26 from getpass import getpass |
26 from getpass import getpass |
|
27 |
|
28 from six import PY2, text_type |
|
29 from six.moves import input |
27 |
30 |
28 from passlib.utils import handlers as uh, to_hash_str |
31 from passlib.utils import handlers as uh, to_hash_str |
29 from passlib.context import CryptContext |
32 from passlib.context import CryptContext |
30 |
33 |
31 from cubicweb.md5crypt import crypt as md5crypt |
34 from cubicweb.md5crypt import crypt as md5crypt |
80 database, (e.g. during tests), eschema.eid is not set. |
83 database, (e.g. during tests), eschema.eid is not set. |
81 """ |
84 """ |
82 if eschema.eid is None: |
85 if eschema.eid is None: |
83 eschema.eid = cnx.execute( |
86 eschema.eid = cnx.execute( |
84 'Any X WHERE X is CWEType, X name %(name)s', |
87 'Any X WHERE X is CWEType, X name %(name)s', |
85 {'name': unicode(eschema)})[0][0] |
88 {'name': text_type(eschema)})[0][0] |
86 return eschema.eid |
89 return eschema.eid |
87 |
90 |
88 |
91 |
89 DEFAULT_MSG = 'we need a manager connection on the repository \ |
92 DEFAULT_MSG = 'we need a manager connection on the repository \ |
90 (the server doesn\'t have to run, even should better not)' |
93 (the server doesn\'t have to run, even should better not)' |
93 passwdmsg='password'): |
96 passwdmsg='password'): |
94 if not user: |
97 if not user: |
95 if msg: |
98 if msg: |
96 print(msg) |
99 print(msg) |
97 while not user: |
100 while not user: |
98 user = raw_input('login: ') |
101 user = input('login: ') |
99 user = unicode(user, sys.stdin.encoding) |
102 if PY2: |
|
103 user = unicode(user, sys.stdin.encoding) |
100 passwd = getpass('%s: ' % passwdmsg) |
104 passwd = getpass('%s: ' % passwdmsg) |
101 if confirm: |
105 if confirm: |
102 while True: |
106 while True: |
103 passwd2 = getpass('confirm password: ') |
107 passwd2 = getpass('confirm password: ') |
104 if passwd == passwd2: |
108 if passwd == passwd2: |