|
1 | 1 | import getpass
|
2 | 2 | import json
|
3 |
| -import os |
4 | 3 |
|
5 | 4 | from subprocess import check_output, STDOUT, CalledProcessError
|
6 | 5 | from typing import Optional, Tuple
|
@@ -70,8 +69,12 @@ def system_default() -> "DenoiseInitialSettings":
|
70 | 69 |
|
71 | 70 |
|
72 | 71 | def _construct_basic_path(env_keys: list[str]) -> list[str]:
|
73 |
| - assert len(env_keys) > 0 |
74 |
| - return ["sudo", "--preserve-env=" + ",".join(env_keys), "-n", paths.get_denoise(), "--json"] |
| 72 | + if len(env_keys) == 0: |
| 73 | + preserve = [] |
| 74 | + else: |
| 75 | + preserve = ["--preserve-env=" + ",".join(env_keys)] |
| 76 | + |
| 77 | + return ["sudo"] + preserve + ["-n", paths.get_denoise(), "--json"] |
75 | 78 |
|
76 | 79 |
|
77 | 80 | def _construct_path(for_profiling: bool, env_keys: list[str]) -> list[str]:
|
@@ -132,9 +135,8 @@ def _add_denoise_exec_options(cmd: list[str], requested: Denoise):
|
132 | 135 |
|
133 | 136 |
|
134 | 137 | def _exec_denoise(cmd: list[str]):
|
135 |
| - env = _get_env_with_python_path_for_denoise() |
136 | 138 | try:
|
137 |
| - output = output_as_str(check_output(cmd, stderr=STDOUT, env=env)) |
| 139 | + output = output_as_str(check_output(cmd, stderr=STDOUT)) |
138 | 140 | except CalledProcessError as e:
|
139 | 141 | output = output_as_str(e.output)
|
140 | 142 | except FileNotFoundError as e:
|
@@ -262,15 +264,12 @@ def minimize_noise(possible_settings: Denoise, for_profiling: bool, show_warning
|
262 | 264 | result, got_json, raw_output, msg, show_warnings, ui, possible_settings)
|
263 | 265 |
|
264 | 266 |
|
265 |
| -def construct_denoise_exec_prefix( |
266 |
| - env, for_profiling, possible_settings: Denoise) -> Tuple[str, dict]: |
267 |
| - env = _add_denoise_python_path_to_env(env) |
| 267 | +def construct_denoise_exec_prefix(env, for_profiling, possible_settings: Denoise) -> str: |
268 | 268 | cmd = _construct_path(for_profiling, env.keys())
|
269 |
| - |
270 | 269 | _add_denoise_exec_options(cmd, possible_settings)
|
271 | 270 |
|
272 | 271 | cmd += ["exec", "--"]
|
273 |
| - return " ".join(cmd) + " ", env |
| 272 | + return " ".join(cmd) + " " |
274 | 273 |
|
275 | 274 | def restore_noise(denoise_result: DenoiseInitialSettings, show_warning, ui):
|
276 | 275 | if denoise_result.nothing_set:
|
|
0 commit comments