##// END OF EJS Templates
split shell.system into shell.system_raw/system_piped...
MinRK -
Show More
@@ -1872,22 +1872,40 b' class InteractiveShell(SingletonConfigurable, Magic):'
1872 # Things related to the running of system commands
1872 # Things related to the running of system commands
1873 #-------------------------------------------------------------------------
1873 #-------------------------------------------------------------------------
1874
1874
1875 def system(self, cmd):
1875 def system_piped(self, cmd):
1876 """Call the given cmd in a subprocess.
1876 """Call the given cmd in a subprocess, piping stdout/err
1877
1877
1878 Parameters
1878 Parameters
1879 ----------
1879 ----------
1880 cmd : str
1880 cmd : str
1881 Command to execute (can not end in '&', as bacground processes are
1881 Command to execute (can not end in '&', as background processes are
1882 not supported.
1882 not supported. Should not be a command that expects input
1883 other than simple text.
1883 """
1884 """
1884 # We do not support backgrounding processes because we either use
1885 if cmd.rstrip().endswith('&'):
1885 # pexpect or pipes to read from. Users can always just call
1886 # this is *far* from a rigorous test
1886 # os.system() if they really want a background process.
1887 # We do not support backgrounding processes because we either use
1887 if cmd.endswith('&'):
1888 # pexpect or pipes to read from. Users can always just call
1889 # os.system() or use ip.system=ip.system_raw
1890 # if they really want a background process.
1888 raise OSError("Background processes not supported.")
1891 raise OSError("Background processes not supported.")
1889
1892
1890 return system(self.var_expand(cmd, depth=2))
1893 # don't return the result, always return None
1894 system(self.var_expand(cmd, depth=2))
1895
1896 def system_raw(self, cmd):
1897 """Call the given cmd in a subprocess using os.system
1898
1899 Parameters
1900 ----------
1901 cmd : str
1902 Command to execute.
1903 """
1904 # don't return the result, always return None
1905 os.system(self.var_expand(cmd, depth=2))
1906
1907 # use piped system by default, because it is better behaved
1908 system = system_piped
1891
1909
1892 def getoutput(self, cmd, split=True):
1910 def getoutput(self, cmd, split=True):
1893 """Get output (possibly including stderr) from a subprocess.
1911 """Get output (possibly including stderr) from a subprocess.
@@ -1905,7 +1923,8 b' class InteractiveShell(SingletonConfigurable, Magic):'
1905 manipulation of line-based output. You can use '?' on them for
1923 manipulation of line-based output. You can use '?' on them for
1906 details.
1924 details.
1907 """
1925 """
1908 if cmd.endswith('&'):
1926 if cmd.rstrip().endswith('&'):
1927 # this is *far* from a rigorous test
1909 raise OSError("Background processes not supported.")
1928 raise OSError("Background processes not supported.")
1910 out = getoutput(self.var_expand(cmd, depth=2))
1929 out = getoutput(self.var_expand(cmd, depth=2))
1911 if split:
1930 if split:
@@ -86,6 +86,12 b' class TerminalInteractiveShell(InteractiveShell):'
86 config=config, ipython_dir=ipython_dir, user_ns=user_ns,
86 config=config, ipython_dir=ipython_dir, user_ns=user_ns,
87 user_global_ns=user_global_ns, custom_exceptions=custom_exceptions
87 user_global_ns=user_global_ns, custom_exceptions=custom_exceptions
88 )
88 )
89 # use os.system instead of utils.process.system by default, except on Windows
90 if os.name == 'nt':
91 self.system = self.system_piped
92 else:
93 self.system = self.system_raw
94
89 self.init_term_title()
95 self.init_term_title()
90 self.init_usage(usage)
96 self.init_usage(usage)
91 self.init_banner(banner1, banner2, display_banner)
97 self.init_banner(banner1, banner2, display_banner)
General Comments 0
You need to be logged in to leave comments. Login now