mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
first step
This commit is contained in:
parent
32d72af53d
commit
a5296f8457
3 changed files with 15 additions and 11 deletions
|
@ -386,10 +386,10 @@ class CommandPipeline:
|
|||
for line in self.iterraw():
|
||||
# write to stdout line ASAP, if needed
|
||||
if stream:
|
||||
if stdout_has_buffer:
|
||||
sys.stdout.buffer.write(line)
|
||||
else:
|
||||
if isinstance(line, bytes):
|
||||
sys.stdout.write(line.decode(encoding=enc, errors=err))
|
||||
else:
|
||||
sys.stdout.write(line)
|
||||
sys.stdout.flush()
|
||||
# save the raw bytes
|
||||
raw_out_lines.append(line)
|
||||
|
|
|
@ -441,7 +441,9 @@ class ProcProxyThread(threading.Thread):
|
|||
# stdout
|
||||
if self.c2pwrite != -1:
|
||||
sp_stdout = io.TextIOWrapper(
|
||||
open(self.c2pwrite, "wb", -1), encoding=enc, errors=err
|
||||
self.stdout
|
||||
# open(self.c2pwrite, "wb", -1)
|
||||
, encoding=enc, errors=err
|
||||
)
|
||||
else:
|
||||
sp_stdout = sys.stdout
|
||||
|
@ -450,7 +452,9 @@ class ProcProxyThread(threading.Thread):
|
|||
sp_stderr = sp_stdout
|
||||
elif self.errwrite != -1:
|
||||
sp_stderr = io.TextIOWrapper(
|
||||
open(self.errwrite, "wb", -1), encoding=enc, errors=err
|
||||
self.stderr
|
||||
# open(self.errwrite, "wb", -1)
|
||||
, encoding=enc, errors=err
|
||||
)
|
||||
else:
|
||||
sp_stderr = sys.stderr
|
||||
|
|
|
@ -912,9 +912,9 @@ def _make_last_spec_captured(last: SubprocSpec):
|
|||
last.universal_newlines = True
|
||||
r, w = xli.pty.openpty() if use_tty else os.pipe()
|
||||
_safe_pipe_properties(w, use_tty=use_tty)
|
||||
last.stdout = safe_open(w, "w")
|
||||
last.stdout = safe_open(w, "wb")
|
||||
_safe_pipe_properties(r, use_tty=use_tty)
|
||||
last.captured_stdout = safe_open(r, "r")
|
||||
last.captured_stdout = safe_open(r, "rb")
|
||||
# set standard error
|
||||
if last.stderr is not None:
|
||||
pass
|
||||
|
@ -922,8 +922,8 @@ def _make_last_spec_captured(last: SubprocSpec):
|
|||
pass
|
||||
elif captured == "object":
|
||||
r, w = os.pipe()
|
||||
last.stderr = safe_open(w, "w")
|
||||
last.captured_stderr = safe_open(r, "r")
|
||||
last.stderr = safe_open(w, "wb")
|
||||
last.captured_stderr = safe_open(r, "rb")
|
||||
elif XSH.stderr_uncaptured is not None:
|
||||
last.stderr = XSH.stderr_uncaptured
|
||||
last.captured_stderr = last.stderr
|
||||
|
@ -933,9 +933,9 @@ def _make_last_spec_captured(last: SubprocSpec):
|
|||
else:
|
||||
r, w = xli.pty.openpty() if use_tty else os.pipe()
|
||||
_safe_pipe_properties(w, use_tty=use_tty)
|
||||
last.stderr = safe_open(w, "w")
|
||||
last.stderr = safe_open(w, "wb")
|
||||
_safe_pipe_properties(r, use_tty=use_tty)
|
||||
last.captured_stderr = safe_open(r, "r")
|
||||
last.captured_stderr = safe_open(r, "rb")
|
||||
# redirect stdout to stderr, if we should
|
||||
if isinstance(last.stdout, int) and last.stdout == 2:
|
||||
# need to use private interface to avoid duplication.
|
||||
|
|
Loading…
Add table
Reference in a new issue