summaryrefslogtreecommitdiff
diff options
authorpeppepetra86 <giuseppe.petralia@canonical.com>2020-08-10 16:16:17 +0200
committerpeppepetra86 <giuseppe.petralia@canonical.com>2020-08-10 16:16:17 +0200
commitda90cb5c01665fb9c033ddee22335410fd4553dc (patch)
tree73b31ca0795f2a65405d50a75a73008632d1bd9a
parentca8264bd14135b0087696d5c17e0913360a011a7 (diff)
Fix install behind proxy.
-rwxr-xr-xhooks/hooks.py14
-rw-r--r--tox.ini4
2 files changed, 9 insertions, 9 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py
index fe10847..a68f06e 100755
--- a/hooks/hooks.py
+++ b/hooks/hooks.py
@@ -40,6 +40,7 @@ from charmhelpers.core.hookenv import (
application_version_set,
close_port,
config,
+ env_proxy_settings,
is_leader,
is_relation_made,
local_unit,
@@ -59,6 +60,7 @@ from charmhelpers.core.host import (
service,
)
from charmhelpers.fetch import add_source, apt_install, apt_update
+from charmhelpers.fetch.python.packages import pip_install
from charmhelpers.payload.execd import execd_preinstall
from yaml.constructor import ConstructorError
@@ -75,15 +77,13 @@ except ImportError:
from pymongo.errors import OperationFailure
try:
- import pip # flake8: noqa
-except ImportError:
- apt_install("python3-pip", fatal=True)
- import pip # flake8: noqa
-
-try:
import distro # flake8: noqa
except ImportError:
- pip.main(["install", "distro"])
+ proxy_settings = env_proxy_settings()
+ proxy = None
+ if proxy_settings and "https_proxy" in proxy_settings:
+ proxy = proxy_settings["https_proxy"]
+ pip_install("distro", proxy=proxy)
import distro # flake8: noqa
diff --git a/tox.ini b/tox.ini
index b50af52..20097ae 100644
--- a/tox.ini
+++ b/tox.ini
@@ -59,8 +59,8 @@ deps =
[testenv:unit]
commands =
coverage run -m unittest discover -s {toxinidir}/tests/unit -v
- coverage report --omit tests/*,mod/*,.tox/*
- coverage html --omit tests/*,mod/*,.tox/*
+ coverage report --omit tests/*,mod/*,.tox/*,charmhelpers/*
+ coverage html --omit tests/*,mod/*,.tox/*,charmhelpers/*
deps = -r{toxinidir}/tests/unit/requirements.txt
[testenv:func]