Show More
@@ -1890,8 +1890,10 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||
|
1890 | 1890 | # if they really want a background process. |
|
1891 | 1891 | raise OSError("Background processes not supported.") |
|
1892 | 1892 | |
|
1893 | # don't return the result, always return None | |
|
1894 | system(self.var_expand(cmd, depth=2)) | |
|
1893 | # we explicitly do NOT return the subprocess status code, because | |
|
1894 | # a non-None value would trigger :func:`sys.displayhook` calls. | |
|
1895 | # Instead, we store the exit_code in user_ns. | |
|
1896 | self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=2)) | |
|
1895 | 1897 | |
|
1896 | 1898 | def system_raw(self, cmd): |
|
1897 | 1899 | """Call the given cmd in a subprocess using os.system |
@@ -1901,8 +1903,10 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||
|
1901 | 1903 | cmd : str |
|
1902 | 1904 | Command to execute. |
|
1903 | 1905 | """ |
|
1904 | # don't return the result, always return None | |
|
1905 | os.system(self.var_expand(cmd, depth=2)) | |
|
1906 | # We explicitly do NOT return the subprocess status code, because | |
|
1907 | # a non-None value would trigger :func:`sys.displayhook` calls. | |
|
1908 | # Instead, we store the exit_code in user_ns. | |
|
1909 | self.user_ns['_exit_code'] = os.system(self.var_expand(cmd, depth=2)) | |
|
1906 | 1910 | |
|
1907 | 1911 | # use piped system by default, because it is better behaved |
|
1908 | 1912 | system = system_piped |
@@ -130,9 +130,7 b' class ProcessHandler(object):' | |||
|
130 | 130 | |
|
131 | 131 | Returns |
|
132 | 132 | ------- |
|
133 | None : we explicitly do NOT return the subprocess status code, as this | |
|
134 | utility is meant to be used extensively in IPython, where any return | |
|
135 | value would trigger :func:`sys.displayhook` calls. | |
|
133 | int : child's exitstatus | |
|
136 | 134 | """ |
|
137 | 135 | pcmd = self._make_cmd(cmd) |
|
138 | 136 | # Patterns to match on the output, for pexpect. We read input and |
@@ -181,6 +179,7 b' class ProcessHandler(object):' | |||
|
181 | 179 | finally: |
|
182 | 180 | # Ensure the subprocess really is terminated |
|
183 | 181 | child.terminate(force=True) |
|
182 | return child.exitstatus | |
|
184 | 183 | |
|
185 | 184 | def _make_cmd(self, cmd): |
|
186 | 185 | return '%s -c "%s"' % (self.sh, cmd) |
@@ -96,6 +96,9 b' def _system_body(p):' | |||
|
96 | 96 | line = line.decode(enc, 'replace') |
|
97 | 97 | print(line, file=sys.stderr) |
|
98 | 98 | |
|
99 | # Wait to finish for returncode | |
|
100 | return p.wait() | |
|
101 | ||
|
99 | 102 | |
|
100 | 103 | def system(cmd): |
|
101 | 104 | """Win32 version of os.system() that works with network shares. |
@@ -116,7 +119,7 b' def system(cmd):' | |||
|
116 | 119 | with AvoidUNCPath() as path: |
|
117 | 120 | if path is not None: |
|
118 | 121 | cmd = '"pushd %s &&"%s' % (path, cmd) |
|
119 | process_handler(cmd, _system_body) | |
|
122 | return process_handler(cmd, _system_body) | |
|
120 | 123 | |
|
121 | 124 | |
|
122 | 125 | def getoutput(cmd): |
General Comments 0
You need to be logged in to leave comments.
Login now