aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
authorAlexis de Talhouët <adetalhouet89@gmail.com>2019-04-19 09:31:54 -0400
committerAlexis de Talhouët <adetalhouet89@gmail.com>2019-04-22 14:23:12 +0000
commit03b4f1fb8136f12f9f7c80ee6dff771384916b7e (patch)
treea62ffc40b50f537c8250b27cc5f8285050070376 /ms
parentf6c08adeb3ec6af94fc75eb4e8f0853ce5f38c97 (diff)
Add support for requirements.txt for pip deps
Change-Id: I10bbe95a4d06ce9361d3ab6553953022e1196a3d Issue-ID: CCCSDK-125 Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms')
-rw-r--r--ms/command-executor/src/main/python/command_executor_handler.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/ms/command-executor/src/main/python/command_executor_handler.py b/ms/command-executor/src/main/python/command_executor_handler.py
index 9eb36fb2d..1fb3e2679 100644
--- a/ms/command-executor/src/main/python/command_executor_handler.py
+++ b/ms/command-executor/src/main/python/command_executor_handler.py
@@ -24,6 +24,8 @@ import venv
import utils
import proto.CommandExecutor_pb2 as CommandExecutor_pb2
+REQUIREMENTS_TXT = "requirements.txt"
+
class CommandExecutorHandler():
@@ -80,12 +82,12 @@ class CommandExecutorHandler():
for package in request.packages:
if package.type == type:
f.write("Installed %s packages:\r\n" % CommandExecutor_pb2.PackageType.Name(type))
- for python_package in package.package:
- f.write(" %s\r\n" % python_package)
+ for p in package.package:
+ f.write(" %s\r\n" % p)
if package.type == CommandExecutor_pb2.pip:
- success = self.install_python_packages(python_package, results)
+ success = self.install_python_packages(p, results)
else:
- success = self.install_ansible_packages(python_package, results)
+ success = self.install_ansible_packages(p, results)
if not success:
f.close()
os.remove(self.installed)
@@ -95,7 +97,11 @@ class CommandExecutorHandler():
def install_python_packages(self, package, results):
self.logger.info(
"{} - Install Python package({}) in Python Virtual Environment".format(self.blueprint_id, package))
- command = ["pip", "install", package]
+
+ if REQUIREMENTS_TXT == package:
+ command = ["pip", "install", "-r", self.venv_home + "/Environments/" + REQUIREMENTS_TXT]
+ else:
+ command = ["pip", "install", package]
env = dict(os.environ)
if "https_proxy" in os.environ: