<s> from __future__ import print_function <EOL> from getpass import getpass <EOL> import sys <EOL> try : <EOL> import ravello_sdk <EOL> ravello_sdk . is_rsaw_sdk ( ) <EOL> except : <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> raise <EOL> def get_username ( prompt = "<STR_LIT>" , defaultUser = None ) : <EOL> """<STR_LIT>""" <EOL> user = raw_input ( prompt ) <EOL> while not len ( user ) : <EOL> if defaultUser : <EOL> user = defaultUser <EOL> else : <EOL> user = raw_input ( "<STR_LIT>" ) <EOL> return user <EOL> def get_passphrase ( prompt = "<STR_LIT>" , defaultPass = None ) : <EOL> """<STR_LIT>""" <EOL> passwd = getpass ( prompt ) <EOL> while not len ( passwd ) : <EOL> if defaultPass : <EOL> passwd = defaultPass <EOL> else : <EOL> passwd = getpass ( "<STR_LIT>" ) <EOL> return passwd <EOL> def login ( rOpt ) : <EOL> """<STR_LIT>""" <EOL> c = rOpt . c <EOL> rClient = ravello_sdk . RavelloClient ( ) <EOL> c . verbose ( "<STR_LIT>" ) <EOL> cfgUser = rOpt . cfgFile . get ( '<STR_LIT>' , None ) <EOL> cfgPass = rOpt . cfgFile . get ( '<STR_LIT>' , None ) <EOL> cfgMesg = rOpt . cfgFile . get ( '<STR_LIT>' , None ) <EOL> if not rOpt . ravelloUser : <EOL> if cfgUser : <EOL> rOpt . ravelloUser = cfgUser <EOL> else : <EOL> rOpt . ravelloUser = get_username ( <EOL> c . CYAN ( "<STR_LIT>" ) ) <EOL> if not rOpt . ravelloPass : <EOL> if cfgPass : <EOL> rOpt . ravelloPass = cfgPass <EOL> else : <EOL> rOpt . ravelloPass = get_passphrase ( <EOL> c . CYAN ( "<STR_LIT>" ) ) <EOL> try : <EOL> rClient . login ( rOpt . ravelloUser , rOpt . ravelloPass ) <EOL> except : <EOL> print ( c . RED ( "<STR_LIT>" ) ) <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> if cfgMesg : print ( cfgMesg ) <EOL> sys . exit ( <NUM_LIT:5> ) <EOL> print ( c . GREEN ( "<STR_LIT>" ) , end = '<STR_LIT>' ) <EOL> if rOpt . enableAdminFuncs : <EOL> print ( c . YELLOW ( "<STR_LIT>" ) , end = "<STR_LIT>" ) <EOL> if rOpt . showAllApps : <EOL> print ( "<STR_LIT:U+0020>" + c . bgRED ( "<STR_LIT>" ) ) <EOL> else : <EOL> print ( ) <EOL> else : <EOL> print ( c . GREEN ( "<STR_LIT>" ) ) <EOL> return rClient </s>
