From 9f9dbc22f1a7dac3cf7dcf8469525a55134363d8 Mon Sep 17 00:00:00 2001 From: Pat Ferate Date: Fri, 8 Jul 2016 08:49:04 -0700 Subject: [PATCH] Clean up command line messages Move messages split up by multiple print calls to multi-line strings. --- oauth2client/tools.py | 51 ++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/oauth2client/tools.py b/oauth2client/tools.py index 9e3e85d..f24b23f 100644 --- a/oauth2client/tools.py +++ b/oauth2client/tools.py @@ -48,6 +48,32 @@ with information from the APIs Console . """ +_FAILED_START_MESSAGE = """ +Failed to start a local webserver listening on either port 8080 +or port 8090. Please check your firewall settings and locally +running programs that may be blocking or using those ports. + +Falling back to --noauth_local_webserver and continuing with +authorization. +""" + +_BROWSER_OPENED_MESSAGE = """ +Your browser has been opened to visit: + + %s + +If your browser is on a different machine then exit and re-run this +application with the command-line parameter + + --noauth_local_webserver +""" + +_GO_TO_LINK_MESSAGE = """ +Go to the following link in your browser: + + %s +""" + def _CreateArgumentParser(): try: @@ -182,14 +208,7 @@ def run_flow(flow, storage, flags=None, http=None): break flags.noauth_local_webserver = not success if not success: - print('Failed to start a local webserver listening ' - 'on either port 8080') - print('or port 8090. Please check your firewall settings and locally') - print('running programs that may be blocking or using those ports.') - print() - print('Falling back to --noauth_local_webserver and continuing with') - print('authorization.') - print() + print(_FAILED_START_MESSAGE) if not flags.noauth_local_webserver: oauth_callback = 'http://%s:%s/' % (flags.auth_host_name, port_number) @@ -201,21 +220,9 @@ def run_flow(flow, storage, flags=None, http=None): if not flags.noauth_local_webserver: import webbrowser webbrowser.open(authorize_url, new=1, autoraise=True) - print('Your browser has been opened to visit:') - print() - print(' ' + authorize_url) - print() - print('If your browser is on a different machine then ' - 'exit and re-run this') - print('application with the command-line parameter ') - print() - print(' --noauth_local_webserver') - print() + print(_BROWSER_OPENED_MESSAGE % authorize_url) else: - print('Go to the following link in your browser:') - print() - print(' ' + authorize_url) - print() + print(_GO_TO_LINK_MESSAGE % authorize_url) code = None if not flags.noauth_local_webserver: