|
618 | 618 | { |
619 | 619 | "data": { |
620 | 620 | "text/plain": [ |
621 | | - "['g', 'a', 'b', 'd', 'f', 'e', 'c', 'h']" |
| 621 | + "['g', 'a', 'f', 'c', 'e', 'd', 'h', 'b']" |
622 | 622 | ] |
623 | 623 | }, |
624 | 624 | "execution_count": null, |
|
1044 | 1044 | "outputs": [], |
1045 | 1045 | "source": [ |
1046 | 1046 | "#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", |
1048 | 1048 | " \"Pass `cmd` (splitting with `shlex` if string) to `subprocess.run`; return `stdout`; raise `IOError` if fails\"\n", |
1049 | 1049 | " if rest: cmd = (cmd,)+rest\n", |
1050 | 1050 | " elif isinstance(cmd,str): cmd = shlex.split(cmd)\n", |
1051 | 1051 | " res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n", |
1052 | 1052 | " stdout = res.stdout\n", |
1053 | | - " if res.stderr: stdout += b' ;; ' + res.stderr\n", |
| 1053 | + " if stderr and res.stderr: stdout += b' ;; ' + res.stderr\n", |
1054 | 1054 | " if not as_bytes: stdout = stdout.decode().strip()\n", |
1055 | 1055 | " if ignore_ex: return (res.returncode, stdout)\n", |
1056 | 1056 | " if res.returncode: raise IOError(stdout)\n", |
|
0 commit comments