From 1fc21c4b8d9fdaa18396473fd8beb031157d8cea Mon Sep 17 00:00:00 2001 From: Keith Maxwell Date: Sun, 25 Jan 2015 13:02:29 +0000 Subject: [PATCH] Use six to call raw_input for Python 3 support In Python 3 `raw_input` was renamed to `input`. Start to use the compatibility library to call the function. https://pythonhosted.org/six/#module-six.moves --- oauth2client/old_run.py | 3 ++- oauth2client/tools.py | 3 ++- samples/oauth2_for_devices.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/oauth2client/old_run.py b/oauth2client/old_run.py index f44fa51616..f433b84ed2 100644 --- a/oauth2client/old_run.py +++ b/oauth2client/old_run.py @@ -23,6 +23,7 @@ import webbrowser import gflags +from six.moves import input from oauth2client import client from oauth2client import util @@ -147,7 +148,7 @@ def run(flow, storage, http=None): print('Failed to find "code" in the query parameters of the redirect.') sys.exit('Try running with --noauth_local_webserver.') else: - code = raw_input('Enter verification code: ').strip() + code = input('Enter verification code: ').strip() try: credential = flow.step2_exchange(code, http=http) diff --git a/oauth2client/tools.py b/oauth2client/tools.py index 23211c138e..235793b9d2 100644 --- a/oauth2client/tools.py +++ b/oauth2client/tools.py @@ -30,6 +30,7 @@ from six.moves import BaseHTTPServer from six.moves import urllib +from six.moves import input from oauth2client import client from oauth2client import util @@ -216,7 +217,7 @@ def run_flow(flow, storage, flags, http=None): print('Failed to find "code" in the query parameters of the redirect.') sys.exit('Try running with --noauth_local_webserver.') else: - code = raw_input('Enter verification code: ').strip() + code = input('Enter verification code: ').strip() try: credential = flow.step2_exchange(code, http=http) diff --git a/samples/oauth2_for_devices.py b/samples/oauth2_for_devices.py index abe32c7551..b419ea44ad 100644 --- a/samples/oauth2_for_devices.py +++ b/samples/oauth2_for_devices.py @@ -3,6 +3,7 @@ # See: https://developers.google.com/accounts/docs/OAuth2ForDevices import httplib2 +from six.moves import input from oauth2client.client import OAuth2WebServerFlow from googleapiclient.discovery import build @@ -18,7 +19,7 @@ print "Enter the following code at %s: %s" % (flow_info.verification_url, flow_info.user_code) print "Then press Enter." -raw_input() +input() # Step 2: get credentials # https://developers.google.com/accounts/docs/OAuth2ForDevices#obtainingatoken