##// END OF EJS Templates
Expose & document depth parameter to ip.getoutput()
Thomas Kluyver -
Show More
@@ -2210,7 +2210,7 b' class InteractiveShell(SingletonConfigurable):'
2210 2210 # use piped system by default, because it is better behaved
2211 2211 system = system_piped
2212 2212
2213 def getoutput(self, cmd, split=True, _depth=0):
2213 def getoutput(self, cmd, split=True, depth=0):
2214 2214 """Get output (possibly including stderr) from a subprocess.
2215 2215
2216 2216 Parameters
@@ -2219,17 +2219,20 b' class InteractiveShell(SingletonConfigurable):'
2219 2219 Command to execute (can not end in '&', as background processes are
2220 2220 not supported.
2221 2221 split : bool, optional
2222
2223 2222 If True, split the output into an IPython SList. Otherwise, an
2224 2223 IPython LSString is returned. These are objects similar to normal
2225 2224 lists and strings, with a few convenience attributes for easier
2226 2225 manipulation of line-based output. You can use '?' on them for
2227 2226 details.
2228 """
2227 depth : int, optional
2228 How many frames above the caller are the local variables which should
2229 be expanded in the command string? The default (0) assumes that the
2230 expansion variables are in the stack frame calling this function.
2231 """
2229 2232 if cmd.rstrip().endswith('&'):
2230 2233 # this is *far* from a rigorous test
2231 2234 raise OSError("Background processes not supported.")
2232 out = getoutput(self.var_expand(cmd, depth=_depth+1))
2235 out = getoutput(self.var_expand(cmd, depth=depth+1))
2233 2236 if split:
2234 2237 out = SList(out.splitlines())
2235 2238 else:
@@ -98,7 +98,7 b' def xsys(self, cmd):'
98 98 """
99 99 # We use getoutput, but we need to strip it because pexpect captures
100 100 # the trailing newline differently from commands.getoutput
101 print(self.getoutput(cmd, split=False, _depth=1).rstrip(), end='', file=sys.stdout)
101 print(self.getoutput(cmd, split=False, depth=1).rstrip(), end='', file=sys.stdout)
102 102 sys.stdout.flush()
103 103
104 104
General Comments 0
You need to be logged in to leave comments. Login now