| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cf8dc25 commit 24d4926
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ | |||
| 46 | 46 | execute_kwargs = set(('istream', 'with_extended_output', | |
| 47 | 47 | 'with_exceptions', 'as_process', 'stdout_as_string', | |
| 48 | 48 | 'output_stream', 'with_stdout', 'kill_after_timeout', | |
| 49 | - 'universal_newlines', 'shell')) | ||
| 49 | + 'universal_newlines', 'shell', 'env')) | ||
| 50 | 50 | ||
| 51 | 51 | log = logging.getLogger(__name__) | |
| 52 | 52 | log.addHandler(logging.NullHandler()) | |
@@ -471,6 +471,7 @@ def execute(self, command, | |||
| 471 | 471 | with_stdout=True, | |
| 472 | 472 | universal_newlines=False, | |
| 473 | 473 | shell=None, | |
| 474 | + env=None, | ||
| 474 | 475 | **subprocess_kwargs | |
| 475 | 476 | ): | |
| 476 | 477 | """Handles executing the command on the shell and consumes and returns | |
@@ -514,6 +515,9 @@ def execute(self, command, | |||
| 514 | 515 | decoded into a string using the default encoding (usually utf-8). | |
| 515 | 516 | The latter can fail, if the output contains binary data. | |
| 516 | 517 | ||
| 518 | + :param env: | ||
| 519 | + A dictionary of environment variables to be passed to `subprocess.Popen`. | ||
| 520 | + | ||
| 517 | 521 | :param subprocess_kwargs: | |
| 518 | 522 | Keyword arguments to be passed to subprocess.Popen. Please note that | |
| 519 | 523 | some of the valid kwargs are already set by this method, the ones you | |
@@ -559,6 +563,7 @@ def execute(self, command, | |||
| 559 | 563 | cwd = self._working_dir or os.getcwd() | |
| 560 | 564 | ||
| 561 | 565 | # Start the process | |
| 566 | + inline_env = env | ||
| 562 | 567 | env = os.environ.copy() | |
| 563 | 568 | # Attempt to force all output to plain ascii english, which is what some parsing code | |
| 564 | 569 | # may expect. | |
@@ -567,6 +572,8 @@ def execute(self, command, | |||
| 567 | 572 | env["LANGUAGE"] = "C" | |
| 568 | 573 | env["LC_ALL"] = "C" | |
| 569 | 574 | env.update(self._environment) | |
| 575 | + if inline_env is not None: | ||
| 576 | + env.update(inline_env) | ||
| 570 | 577 | ||
| 571 | 578 | if is_win: | |
| 572 | 579 | cmd_not_found_exception = OSError | |
| Back | FazBrowse Home | New Git URL |
0 commit comments