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): """