mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-27 13:31:08 -05:00
Made password getting more standard.
This commit is contained in:
parent
398045b1e4
commit
92ed968ed0
@ -69,7 +69,7 @@ def main():
|
|||||||
name = options.name
|
name = options.name
|
||||||
|
|
||||||
if not options.password:
|
if not options.password:
|
||||||
password = something('What is %s\'s password?' % name)
|
password = getpass('What is %s\'s password? ' % name)
|
||||||
else:
|
else:
|
||||||
password = options.password
|
password = options.password
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ def main():
|
|||||||
public servers don't. If you try to connect to a server and for some
|
public servers don't. If you try to connect to a server and for some
|
||||||
reason it just won't work, it might be that you need to set a
|
reason it just won't work, it might be that you need to set a
|
||||||
password.""")
|
password.""")
|
||||||
serverpassword = anything('What password? If you decided not to use '
|
serverpassword = getpass('What password? If you decided not to use '
|
||||||
'a password, just press enter. ')
|
'a password, just press enter. ')
|
||||||
|
|
||||||
myPrint("""Of course, having an IRC bot isn't the most useful thing in the
|
myPrint("""Of course, having an IRC bot isn't the most useful thing in the
|
||||||
@ -414,7 +414,7 @@ def main():
|
|||||||
u.addCapability('owner')
|
u.addCapability('owner')
|
||||||
ircdb.users.setUser(id, u)
|
ircdb.users.setUser(id, u)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
password = something('What should the owner\'s password be?')
|
password = getpass('What should the owner\'s password be?')
|
||||||
(id, u) = ircdb.users.newUser()
|
(id, u) = ircdb.users.newUser()
|
||||||
u.name = name
|
u.name = name
|
||||||
u.setPassword(password)
|
u.setPassword(password)
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
"""Handles interactive questions; useful for wizards and whatnot."""
|
"""Handles interactive questions; useful for wizards and whatnot."""
|
||||||
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
from getpass import getpass as getPass
|
||||||
|
|
||||||
def expect(prompt, possibilities, recursed=False, doindent=True):
|
def expect(prompt, possibilities, recursed=False, doindent=True):
|
||||||
"""Prompt the user with prompt, allow them to choose from possibilities.
|
"""Prompt the user with prompt, allow them to choose from possibilities.
|
||||||
@ -97,5 +98,20 @@ def yn(prompt):
|
|||||||
"""Allow only 'y' or 'n' from the user."""
|
"""Allow only 'y' or 'n' from the user."""
|
||||||
return expect(prompt, ['y', 'n'], doindent=False)
|
return expect(prompt, ['y', 'n'], doindent=False)
|
||||||
|
|
||||||
|
def getpass(prompt='Enter password: '):
|
||||||
|
password = ''
|
||||||
|
password2 = ' '
|
||||||
|
assert prompt
|
||||||
|
if not prompt[-1].isspace():
|
||||||
|
prompt += ' '
|
||||||
|
while True:
|
||||||
|
password = getPass(prompt)
|
||||||
|
password2 = getPass('Re-enter password: ')
|
||||||
|
if password != password2:
|
||||||
|
print 'Passwords don\'t match.'
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return password
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user