mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-03-02 20:40:45 +01:00
Made password getting more standard.
This commit is contained in:
parent
398045b1e4
commit
92ed968ed0
@ -69,7 +69,7 @@ def main():
|
||||
name = options.name
|
||||
|
||||
if not options.password:
|
||||
password = something('What is %s\'s password?' % name)
|
||||
password = getpass('What is %s\'s password? ' % name)
|
||||
else:
|
||||
password = options.password
|
||||
|
||||
|
@ -323,8 +323,8 @@ def main():
|
||||
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
|
||||
password.""")
|
||||
serverpassword = anything('What password? If you decided not to use '
|
||||
'a password, just press enter.')
|
||||
serverpassword = getpass('What password? If you decided not to use '
|
||||
'a password, just press enter. ')
|
||||
|
||||
myPrint("""Of course, having an IRC bot isn't the most useful thing in the
|
||||
world unless you can make that bot join some channels.""")
|
||||
@ -414,7 +414,7 @@ def main():
|
||||
u.addCapability('owner')
|
||||
ircdb.users.setUser(id, u)
|
||||
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()
|
||||
u.name = name
|
||||
u.setPassword(password)
|
||||
|
@ -32,6 +32,7 @@
|
||||
"""Handles interactive questions; useful for wizards and whatnot."""
|
||||
|
||||
import textwrap
|
||||
from getpass import getpass as getPass
|
||||
|
||||
def expect(prompt, possibilities, recursed=False, doindent=True):
|
||||
"""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."""
|
||||
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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user