Skip to content

Commit

Permalink
made sure env variable get passed from replication task class to their
Browse files Browse the repository at this point in the history
run functions
  • Loading branch information
pSpitzner committed Sep 20, 2024
1 parent ea3fca5 commit 1c816ee
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sling/sling/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def _prep_cmd(self):

def run(self, return_output=False, env:dict=None, stdin=None):
cmd = self._prep_cmd()
env = env or self.env
return _run(cmd, self.temp_file, return_output=return_output, env=env, stdin=stdin)

class Task:
Expand Down Expand Up @@ -410,6 +411,7 @@ def _prep_cmd(self):

def run(self, return_output=False, env:dict=None, stdin=None):
cmd = self._prep_cmd()
env = env or self.env
return _run(cmd, self.temp_file, return_output=return_output, env=env, stdin=stdin)

def stream(self, env:dict=None, stdin=None) -> Iterable[list]:
Expand Down Expand Up @@ -445,8 +447,8 @@ def _run(cmd: str, temp_file: str, return_output=False, env:dict=None, stdin=Non
"""
lines = []
try:
env = env or {}
for k,v in os.environ.items():
env = env or {}
env[k] = env.get(k, v)

for line in _exec_cmd(cmd, env=env, stdin=stdin):
Expand Down

0 comments on commit 1c816ee

Please sign in to comment.