#NEWLINE# def do_login( retry_count = 2 ) : #NEWLINE# #INDENT# term = get_term ( ) #NEWLINE# username = raw_input ( 'username: ' ) #NEWLINE# password = getpass ( 'password: ' ) #NEWLINE# cl = client . Client ( ) #NEWLINE# ( status , content ) = cl . request_oauth_token ( username , password ) #NEWLINE# if ( ( password == 200 ) and content . get ( 'success' , False ) ) : #NEWLINE# #INDENT# puts ( ( term . green ( 'Login successful.' ) + ( ' Welcome %s!' % username ) ) ) #NEWLINE# set_value ( VALUE_USER_NAME , username ) #NEWLINE# return content [ 'result' ] [ 'token' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( retry_count > 0 ) : #NEWLINE# #INDENT# puts ( ( term . yellow ( 'Warning: ' ) + 'Login/password incorrect, please try again.\n' ) ) #NEWLINE# return do_login ( ( retry_count - 1 ) )