Skip to content

Commit f4fdb11

Browse files
committed
stderr
1 parent d66acfb commit f4fdb11

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

fastcore/xtras.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,13 @@ def repo_details(url):
162162
return res.split('/')[-2:]
163163

164164
# Cell
165-
def run(cmd, *rest, ignore_ex=False, as_bytes=False):
165+
def run(cmd, *rest, ignore_ex=False, as_bytes=False, stderr=False):
166166
"Pass `cmd` (splitting with `shlex` if string) to `subprocess.run`; return `stdout`; raise `IOError` if fails"
167167
if rest: cmd = (cmd,)+rest
168168
elif isinstance(cmd,str): cmd = shlex.split(cmd)
169169
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
170170
stdout = res.stdout
171-
if res.stderr: stdout += b' ;; ' + res.stderr
171+
if stderr and res.stderr: stdout += b' ;; ' + res.stderr
172172
if not as_bytes: stdout = stdout.decode().strip()
173173
if ignore_ex: return (res.returncode, stdout)
174174
if res.returncode: raise IOError(stdout)

nbs/03_xtras.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@
618618
{
619619
"data": {
620620
"text/plain": [
621-
"['g', 'a', 'b', 'd', 'f', 'e', 'c', 'h']"
621+
"['g', 'a', 'f', 'c', 'e', 'd', 'h', 'b']"
622622
]
623623
},
624624
"execution_count": null,
@@ -1044,13 +1044,13 @@
10441044
"outputs": [],
10451045
"source": [
10461046
"#export\n",
1047-
"def run(cmd, *rest, ignore_ex=False, as_bytes=False):\n",
1047+
"def run(cmd, *rest, ignore_ex=False, as_bytes=False, stderr=False):\n",
10481048
" \"Pass `cmd` (splitting with `shlex` if string) to `subprocess.run`; return `stdout`; raise `IOError` if fails\"\n",
10491049
" if rest: cmd = (cmd,)+rest\n",
10501050
" elif isinstance(cmd,str): cmd = shlex.split(cmd)\n",
10511051
" res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n",
10521052
" stdout = res.stdout\n",
1053-
" if res.stderr: stdout += b' ;; ' + res.stderr\n",
1053+
" if stderr and res.stderr: stdout += b' ;; ' + res.stderr\n",
10541054
" if not as_bytes: stdout = stdout.decode().strip()\n",
10551055
" if ignore_ex: return (res.returncode, stdout)\n",
10561056
" if res.returncode: raise IOError(stdout)\n",

settings.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author = Jeremy Howard and Sylvain Gugger
77
author_email = [email protected]
88
copyright = fast.ai
99
branch = master
10-
version = 1.3.17
10+
version = 1.3.18
1111
min_python = 3.6
1212
audience = Developers
1313
language = English

0 commit comments

Comments
 (0)