Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: third_party/oauth2client/old_run.py

Issue 1094533003: Revert of Upgrade 3rd packages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/oauth2client/multistore_file.py ('k') | third_party/oauth2client/service_account.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/oauth2client/old_run.py
diff --git a/third_party/oauth2client/old_run.py b/third_party/oauth2client/old_run.py
index 221fff86b20926982eb029845cf9cc7dfa917001..da2335848631dd5df46e7343ba20de5a8e01185b 100644
--- a/third_party/oauth2client/old_run.py
+++ b/third_party/oauth2client/old_run.py
@@ -1,4 +1,4 @@
-# Copyright 2014 Google Inc. All rights reserved.
+# Copyright (C) 2013 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
"""This module holds the old run() function which is deprecated, the
tools.run_flow() function should be used in its place."""
-from __future__ import print_function
import logging
import socket
@@ -23,9 +22,9 @@
import webbrowser
import gflags
-from third_party.six.moves import input
-from third_party.oauth2client import client
-from third_party.oauth2client import util
+
+from oauth2client import client
+from oauth2client import util
from tools import ClientRedirectHandler
from tools import ClientRedirectServer
@@ -49,38 +48,39 @@
def run(flow, storage, http=None):
"""Core code for a command-line application.
- The ``run()`` function is called from your application and runs
- through all the steps to obtain credentials. It takes a ``Flow``
- argument and attempts to open an authorization server page in the
- user's default web browser. The server asks the user to grant your
- application access to the user's data. If the user grants access,
- the ``run()`` function returns new credentials. The new credentials
- are also stored in the ``storage`` argument, which updates the file
- associated with the ``Storage`` object.
+ The run() function is called from your application and runs through all
+ the steps to obtain credentials. It takes a Flow argument and attempts to
+ open an authorization server page in the user's default web browser. The
+ server asks the user to grant your application access to the user's data.
+ If the user grants access, the run() function returns new credentials. The
+ new credentials are also stored in the Storage argument, which updates the
+ file associated with the Storage object.
It presumes it is run from a command-line application and supports the
following flags:
- ``--auth_host_name`` (string, default: ``localhost``)
- Host name to use when running a local web server to handle
- redirects during OAuth authorization.
+ --auth_host_name: Host name to use when running a local web server
+ to handle redirects during OAuth authorization.
+ (default: 'localhost')
- ``--auth_host_port`` (integer, default: ``[8080, 8090]``)
- Port to use when running a local web server to handle redirects
- during OAuth authorization. Repeat this option to specify a list
- of values.
+ --auth_host_port: Port to use when running a local web server to handle
+ redirects during OAuth authorization.;
+ repeat this option to specify a list of values
+ (default: '[8080, 8090]')
+ (an integer)
- ``--[no]auth_local_webserver`` (boolean, default: ``True``)
- Run a local web server to handle redirects during OAuth authorization.
+ --[no]auth_local_webserver: Run a local web server to handle redirects
+ during OAuth authorization.
+ (default: 'true')
- Since it uses flags make sure to initialize the ``gflags`` module before
- calling ``run()``.
+ Since it uses flags make sure to initialize the gflags module before
+ calling run().
Args:
flow: Flow, an OAuth 2.0 Flow to step through.
- storage: Storage, a ``Storage`` to store the credential in.
- http: An instance of ``httplib2.Http.request`` or something that acts
- like it.
+ storage: Storage, a Storage to store the credential in.
+ http: An instance of httplib2.Http.request
+ or something that acts like it.
Returns:
Credentials, the obtained credential.
@@ -96,20 +96,20 @@
try:
httpd = ClientRedirectServer((FLAGS.auth_host_name, port),
ClientRedirectHandler)
- except socket.error as e:
+ except socket.error, e:
pass
else:
success = True
break
FLAGS.auth_local_webserver = success
if not success:
- print('Failed to start a local webserver listening on either port 8080')
- print('or port 9090. 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 to start a local webserver listening on either port 8080'
+ print 'or port 9090. 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
if FLAGS.auth_local_webserver:
oauth_callback = 'http://%s:%s/' % (FLAGS.auth_host_name, port_number)
@@ -120,20 +120,20 @@
if FLAGS.auth_local_webserver:
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')
- print('this application with the command-line parameter ')
- print()
- print(' --noauth_local_webserver')
- print()
+ 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'
+ print 'this application with the command-line parameter '
+ print
+ print ' --noauth_local_webserver'
+ print
else:
- print('Go to the following link in your browser:')
- print()
- print(' ' + authorize_url)
- print()
+ print 'Go to the following link in your browser:'
+ print
+ print ' ' + authorize_url
+ print
code = None
if FLAGS.auth_local_webserver:
@@ -143,18 +143,18 @@
if 'code' in httpd.query_params:
code = httpd.query_params['code']
else:
- print('Failed to find "code" in the query parameters of the redirect.')
+ print 'Failed to find "code" in the query parameters of the redirect.'
sys.exit('Try running with --noauth_local_webserver.')
else:
- code = input('Enter verification code: ').strip()
+ code = raw_input('Enter verification code: ').strip()
try:
credential = flow.step2_exchange(code, http=http)
- except client.FlowExchangeError as e:
+ except client.FlowExchangeError, e:
sys.exit('Authentication has failed: %s' % e)
storage.put(credential)
credential.set_store(storage)
- print('Authentication successful.')
+ print 'Authentication successful.'
- return credential
+ return credential
« no previous file with comments | « third_party/oauth2client/multistore_file.py ('k') | third_party/oauth2client/service_account.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698