<s> from getpass import getpass <EOL> from ... gafferd . util import confirm <EOL> from ... httpclient . base import GafferNotFound <EOL> from ... httpclient . users import Users <EOL> from . base import Command <EOL> class UserSetPassword ( Command ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> short_descr = "<STR_LIT>" <EOL> def run ( self , config , args ) : <EOL> server = config . get ( '<STR_LIT>' ) <EOL> password = args [ '<STR_LIT>' ] <EOL> try : <EOL> if password is None : <EOL> while True : <EOL> password = getpass ( "<STR_LIT>" ) <EOL> if password and password is not None : <EOL> break <EOL> print ( "<STR_LIT>" ) <EOL> while True : <EOL> confirm_password = getpass ( "<STR_LIT>" ) <EOL> if confirm_password == password : <EOL> break <EOL> except KeyboardInterrupt : <EOL> return <EOL> if not confirm ( "<STR_LIT>" % args [ '<STR_LIT>' ] ) : <EOL> return <EOL> users = Users ( server ) <EOL> try : <EOL> user = users . set_password ( args [ '<STR_LIT>' ] , password ) <EOL> except GafferNotFound : <EOL> raise RuntimeError ( "<STR_LIT>" % args [ '<STR_LIT>' ] ) <EOL> print ( "<STR_LIT>" % args [ '<STR_LIT>' ] ) </s>
