diff --git a/.dockerignore b/.dockerignore index 9fa26a3..9a1c280 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ ** !docker-entrypoint.sh -!iriscli \ No newline at end of file +!iriscli +!iris_ipm.py \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 93c4485..64866c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,7 +60,10 @@ COPY --from=0 --chown=${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /usr/iriss ENV PATH="$PATH:/home/irisowner/.local/bin" -RUN pip install irissqlcli +COPY iris_ipm.py /usr/irissys/lib/python/ + +RUN pip install irissqlcli && \ + cat /usr/irissys/lib/python/iris_ipm.py >> /usr/irissys/lib/python/iris.py COPY iriscli /home/irisowner/bin/ @@ -88,7 +91,10 @@ COPY --from=0 --chown=${ISC_PACKAGE_MGRUSER}:${ISC_PACKAGE_IRISGROUP} /usr/iriss ENV PATH="$PATH:/home/irisowner/.local/bin" -RUN pip install irissqlcli +COPY iris_ipm.py /usr/irissys/lib/python/ + +RUN pip install irissqlcli && \ + cat /usr/irissys/lib/python/iris_ipm.py >> /usr/irissys/lib/python/iris.py COPY iriscli /home/irisowner/bin/ diff --git a/iris_ipm.py b/iris_ipm.py new file mode 100644 index 0000000..430d9f5 --- /dev/null +++ b/iris_ipm.py @@ -0,0 +1,41 @@ +def ipm(cmd, *args): + """ + Executes shell command with IPM: + + Parameters + ---------- + cmd : str + The command to execute + + Examples + -------- + `ipm('help')` + `ipm('load /home/irisowner/dev -v')` + `ipm('install webterminal')` + """ + + import multiprocessing + + def shell(cmd, status): + import iris + + status.put(True) + + res = iris.cls("%ZPM.PackageManager").Shell(cmd) + print('') + if res != 1: + status.get() + status.put(False) + + manager = multiprocessing.Manager() + status = manager.Queue() + process = multiprocessing.Process( + target=shell, + args=( + cmd, + status, + ), + ) + process.start() + process.join() + return status.get()