Bring back tools.run(), but only conditionally on gflags.
Add a warning that tools.run() is deprecated and will be removed in a future
version.
Reviewed in https://codereview.appspot.com/9772046/.
diff --git a/oauth2client/tools.py b/oauth2client/tools.py
index e283a8a..8f01717 100644
--- a/oauth2client/tools.py
+++ b/oauth2client/tools.py
@@ -20,7 +20,7 @@
"""
__author__ = 'jcgregorio@google.com (Joe Gregorio)'
-__all__ = ['argparser', 'run', 'message_if_missing']
+__all__ = ['argparser', 'run_flow', 'run', 'message_if_missing']
import BaseHTTPServer
@@ -107,7 +107,7 @@
@util.positional(3)
-def run(flow, storage, flags, http=None):
+def run_flow(flow, storage, flags, http=None):
"""Core code for a command-line application.
The run() function is called from your application and runs through all the
@@ -231,3 +231,12 @@
"""Helpful message to display if the CLIENT_SECRETS file is missing."""
return _CLIENT_SECRETS_MESSAGE % filename
+
+try:
+ from old_run import run
+except ImportError:
+ def run(*args, **kwargs):
+ raise NotImplementedError(
+ 'The gflags library must be installed to use tools.run(). '
+ 'Please install gflags or preferrably switch to using '
+ 'tools.run_flow().')