From b738e17fb6b3db240758c31691d7c7977666bfd1 Mon Sep 17 00:00:00 2001 From: W Chan Date: Fri, 2 Aug 2019 01:05:14 +0000 Subject: [PATCH] Update all dist_utils instances Update all the dist_utils instances in the project as a result of changes made to scripts/dist_utils.py. --- .../runners/action_chain_runner/dist_utils.py | 31 +++++++++++++------ .../runners/announcement_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/http_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/inquirer_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/local_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/mistral_v2/dist_utils.py | 31 +++++++++++++------ contrib/runners/noop_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/orquesta_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/python_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/remote_runner/dist_utils.py | 31 +++++++++++++------ contrib/runners/winrm_runner/dist_utils.py | 31 +++++++++++++------ st2actions/dist_utils.py | 31 +++++++++++++------ st2api/dist_utils.py | 31 +++++++++++++------ st2auth/dist_utils.py | 31 +++++++++++++------ st2client/dist_utils.py | 31 +++++++++++++------ st2common/dist_utils.py | 31 +++++++++++++------ st2debug/dist_utils.py | 31 +++++++++++++------ st2exporter/dist_utils.py | 31 +++++++++++++------ st2reactor/dist_utils.py | 31 +++++++++++++------ st2stream/dist_utils.py | 31 +++++++++++++------ st2tests/dist_utils.py | 31 +++++++++++++------ 21 files changed, 462 insertions(+), 189 deletions(-) diff --git a/contrib/runners/action_chain_runner/dist_utils.py b/contrib/runners/action_chain_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/action_chain_runner/dist_utils.py +++ b/contrib/runners/action_chain_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/announcement_runner/dist_utils.py b/contrib/runners/announcement_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/announcement_runner/dist_utils.py +++ b/contrib/runners/announcement_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/http_runner/dist_utils.py b/contrib/runners/http_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/http_runner/dist_utils.py +++ b/contrib/runners/http_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/inquirer_runner/dist_utils.py b/contrib/runners/inquirer_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/inquirer_runner/dist_utils.py +++ b/contrib/runners/inquirer_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/local_runner/dist_utils.py b/contrib/runners/local_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/local_runner/dist_utils.py +++ b/contrib/runners/local_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/mistral_v2/dist_utils.py b/contrib/runners/mistral_v2/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/mistral_v2/dist_utils.py +++ b/contrib/runners/mistral_v2/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/noop_runner/dist_utils.py b/contrib/runners/noop_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/noop_runner/dist_utils.py +++ b/contrib/runners/noop_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/orquesta_runner/dist_utils.py b/contrib/runners/orquesta_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/orquesta_runner/dist_utils.py +++ b/contrib/runners/orquesta_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/python_runner/dist_utils.py b/contrib/runners/python_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/python_runner/dist_utils.py +++ b/contrib/runners/python_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/remote_runner/dist_utils.py b/contrib/runners/remote_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/remote_runner/dist_utils.py +++ b/contrib/runners/remote_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/contrib/runners/winrm_runner/dist_utils.py b/contrib/runners/winrm_runner/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/contrib/runners/winrm_runner/dist_utils.py +++ b/contrib/runners/winrm_runner/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2actions/dist_utils.py b/st2actions/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2actions/dist_utils.py +++ b/st2actions/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2api/dist_utils.py b/st2api/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2api/dist_utils.py +++ b/st2api/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2auth/dist_utils.py b/st2auth/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2auth/dist_utils.py +++ b/st2auth/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2client/dist_utils.py b/st2client/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2client/dist_utils.py +++ b/st2client/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2common/dist_utils.py b/st2common/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2common/dist_utils.py +++ b/st2common/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2debug/dist_utils.py b/st2debug/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2debug/dist_utils.py +++ b/st2debug/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2exporter/dist_utils.py b/st2exporter/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2exporter/dist_utils.py +++ b/st2exporter/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2reactor/dist_utils.py b/st2reactor/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2reactor/dist_utils.py +++ b/st2reactor/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2stream/dist_utils.py b/st2stream/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2stream/dist_utils.py +++ b/st2stream/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """ diff --git a/st2tests/dist_utils.py b/st2tests/dist_utils.py index 370d5e0550..140a1fe630 100644 --- a/st2tests/dist_utils.py +++ b/st2tests/dist_utils.py @@ -32,16 +32,8 @@ GET_PIP = 'curl https://bootstrap.pypa.io/get-pip.py | python' -try: - import pip -except ImportError as e: - print('Failed to import pip: %s' % (text_type(e))) - print('') - print('Download pip:\n%s' % (GET_PIP)) - sys.exit(1) - - __all__ = [ + 'check_pip_is_installed', 'check_pip_version', 'fetch_requirements', 'apply_vagrant_workaround', @@ -50,10 +42,29 @@ ] +def check_pip_is_installed(): + """ + Ensure that pip is installed. + """ + try: + import pip # NOQA + except ImportError as e: + print('Failed to import pip: %s' % (text_type(e))) + print('') + print('Download pip:\n%s' % (GET_PIP)) + sys.exit(1) + + return True + + def check_pip_version(min_version='6.0.0'): """ Ensure that a minimum supported version of pip is installed. """ + check_pip_is_installed() + + import pip + if StrictVersion(pip.__version__) < StrictVersion(min_version): print("Upgrade pip, your version '{0}' " "is outdated. Minimum required version is '{1}':\n{2}".format(pip.__version__, @@ -61,6 +72,8 @@ def check_pip_version(min_version='6.0.0'): GET_PIP)) sys.exit(1) + return True + def fetch_requirements(requirements_file_path): """