##// END OF EJS Templates
create new --raise-error argument to raise an error if nonzero exitcode
M Pacer -
Show More
@@ -8,7 +8,7 b' import os'
8 import sys
8 import sys
9 import signal
9 import signal
10 import time
10 import time
11 from subprocess import Popen, PIPE
11 from subprocess import Popen, PIPE, CalledProcessError
12 import atexit
12 import atexit
13
13
14 from IPython.core import magic_arguments
14 from IPython.core import magic_arguments
@@ -54,6 +54,12 b' def script_args(f):'
54 This is used only when --bg option is given.
54 This is used only when --bg option is given.
55 """
55 """
56 ),
56 ),
57 magic_arguments.argument(
58 '--raise-error', action="store_true",
59 help="""Whether you should raise an error message in addition to
60 a stream on stderr if you get a nonzero exit code.
61 """
62 )
57 ]
63 ]
58 for arg in args:
64 for arg in args:
59 f = arg(f)
65 f = arg(f)
@@ -235,6 +241,8 b' class ScriptMagics(Magics):'
235 else:
241 else:
236 sys.stderr.write(err)
242 sys.stderr.write(err)
237 sys.stderr.flush()
243 sys.stderr.flush()
244 if args.raise_error and p.returncode!=0:
245 raise CalledProcessError(p.returncode, cell, output=out, stderr=err)
238
246
239 def _run_script(self, p, cell, to_close):
247 def _run_script(self, p, cell, to_close):
240 """callback for running the script in the background"""
248 """callback for running the script in the background"""
General Comments 0
You need to be logged in to leave comments. Login now