Skip to content

Commit 062a6a3

Browse files
author
Kartik Raj
authored
Fix conda run output marker script (#18412) (#18413)
1 parent 2dd13d9 commit 062a6a3

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

pythonFiles/get_output_via_markers.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010
print(">>>PYTHON-EXEC-OUTPUT")
1111

1212
module = sys.argv[1]
13-
if module == "-c":
14-
ns = {}
15-
for code in sys.argv[2:]:
16-
exec(code, ns, ns)
17-
elif module.startswith("-"):
18-
raise NotImplementedError(sys.argv)
19-
elif module.endswith(".py"):
20-
runpy.run_path(module, run_name="__main__")
21-
else:
22-
runpy.run_module(module, run_name="__main__", alter_sys=True)
23-
24-
print("<<<PYTHON-EXEC-OUTPUT")
13+
try:
14+
if module == "-c":
15+
ns = {}
16+
for code in sys.argv[2:]:
17+
exec(code, ns, ns)
18+
elif module.startswith("-m"):
19+
moduleName = sys.argv[2]
20+
sys.argv = sys.argv[2:] # It should begin with the module name.
21+
runpy.run_module(moduleName, run_name="__main__", alter_sys=True)
22+
elif module.endswith(".py"):
23+
sys.argv = sys.argv[1:]
24+
runpy.run_path(module, run_name="__main__")
25+
elif module.startswith("-"):
26+
raise NotImplementedError(sys.argv)
27+
else:
28+
runpy.run_module(module, run_name="__main__", alter_sys=True)
29+
finally:
30+
print("<<<PYTHON-EXEC-OUTPUT")

src/client/common/process/rawProcessApis.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ function filterOutputUsingCondaRunMarkers(stdout: string) {
164164
// run, see `get_output_via_markers.py`.
165165
const regex = />>>PYTHON-EXEC-OUTPUT([\s\S]*)<<<PYTHON-EXEC-OUTPUT/;
166166
const match = stdout.match(regex);
167-
const filteredOut = match !== null && match.length >= 2 ? match[1].trim() : '';
168-
return filteredOut.length ? filteredOut : stdout;
167+
const filteredOut = match !== null && match.length >= 2 ? match[1].trim() : undefined;
168+
return filteredOut !== undefined ? filteredOut : stdout;
169169
}
170170

171171
function removeCondaRunMarkers(out: string) {

0 commit comments

Comments
 (0)