Skip to content

Commit

Permalink
pass env into sub process
Browse files Browse the repository at this point in the history
  • Loading branch information
nilupulmanodya committed Nov 11, 2023
1 parent 35a1d4b commit 0ec5e9f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mslib/mscolab/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from mslib.utils.qt import Worker, Updater
from mslib.mscolab import mscolab
from mslib.msidp import idp_conf
from os import environ


def handle_start(args):
Expand Down Expand Up @@ -273,6 +274,7 @@ def handle_mscolab_metadata_init(repo_exists):
print('generating metadata file for the mscolab server')

try:
env = environ.copy()
command = ["python", mscolab.__file__, "start"] if repo_exists else ["mscolab", "start"]
process = subprocess.Popen(command)

Expand All @@ -281,7 +283,7 @@ def handle_mscolab_metadata_init(repo_exists):

cmd_curl = ["curl", "http://localhost:8083/metadata/localhost_test_idp",
"-o", f"{mscolab_settings.MSCOLAB_SSO_DIR}/metadata_sp.xml"]
subprocess.run(cmd_curl, check=True)
subprocess.run(cmd_curl, env=env, check=True)
process.terminate()
print('mscolab metadata file generated succesfully')
return True
Expand All @@ -306,10 +308,11 @@ def handle_local_idp_metadata_init(repo_exists):
idp_conf_path = os.path.join(site_packages_path, "mslib/msidp/idp_conf.py")

cmd = ["make_metadata", idp_conf_path]
env = environ.copy()

with open(f"{mscolab_settings.MSCOLAB_SSO_DIR}/idp.xml",
"w", encoding="utf-8") as output_file:
subprocess.run(cmd, stdout=output_file, check=True)
subprocess.run(cmd, stdout=output_file, check=True, env=env)
print("idp metadata file generated succesfully")
return True
except subprocess.CalledProcessError as error:
Expand Down

0 comments on commit 0ec5e9f

Please sign in to comment.