Skip to content

Commit

Permalink
Display outputs and errors of command executed with --pipe or `--ch…
Browse files Browse the repository at this point in the history
…ecks`

#432
  • Loading branch information
mwouts committed Mar 9, 2020
1 parent 8a1bab3 commit abe7616
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- The new jupyterlab extension (in version 1.2.0) is compatible with JupyterLab 2.0. Many thanks to Jean Helie! (#449)
- It is not compatible with JupyterLab 1.x anymore. If you wish, you can install manually the previous version of the extension with `jupyter labextension install jupyterlab-jupytext@1.1.1`.

**Fixed**
- Display the output/errors of command executed with `jupytext --pipe` or `jupytext --check` (#432)

1.3.5 (2020-03-08)
------------------
Expand Down
9 changes: 7 additions & 2 deletions jupytext/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,13 +625,18 @@ def exec_command(command, input=None):
"""Execute the desired command, and pipe the given input into it"""
if not isinstance(command, list):
command = command.split(' ')
sys.stdout.write("[jupytext] Executing {}\n".format(' '.join(command)))
process = subprocess.Popen(command,
**(dict(stdout=subprocess.PIPE, stdin=subprocess.PIPE) if input is not None else {}))
out, err = process.communicate(input=input)
if out:
sys.stdout.write(out.decode('utf-8'))
if err:
sys.stderr.write(err.decode('utf-8'))

if process.returncode:
sys.stderr.write("The command {} exited with code {}{}"
.format(command, process.returncode, ': {}'.format(err or out) if err or out else ''))
sys.stderr.write("[jupytext] Error: The command '{}' exited with code {}\n"
.format(' '.join(command), process.returncode))
raise SystemExit(process.returncode)

return out
Expand Down

0 comments on commit abe7616

Please sign in to comment.