提交 21c13fb3 编写于 作者: J Jacob Champion 提交者: Xin Zhang

isolation2: add an exit-code-only execution mode

We don't want to diff the output from `segwalrep.py recoverfull`, but we
do want to know if the command has succeeded or not. Add a new execution
mode, invoked via

    !\retcode EXECUTABLE [OPTIONS ...]

which will bracket the program's stdout/stderr with begin/end_ignore,
and also print out an exit code (which is not ignored).
上级 4199c12e
......@@ -269,9 +269,29 @@ class SQLIsolationExecutor(object):
sql = sql_parts[1]
if not flag:
if sql.startswith('!'):
cmd_output = subprocess.Popen(sql[1:].strip(), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True)
sql = sql[1:]
# Check for execution mode. E.g.
# !\retcode path/to/executable --option1 --option2 ...
#
# At the moment, we only recognize the \retcode mode, which
# ignores all program output in the diff (it's still printed)
# and adds the return code.
mode = None
if sql.startswith('\\'):
mode, sql = sql.split(None, 1)
if mode != '\\retcode':
raise Exception('Invalid execution mode: {}'.format(mode))
cmd_output = subprocess.Popen(sql.strip(), stderr=subprocess.STDOUT, stdout=subprocess.PIPE, shell=True)
stdout, _ = cmd_output.communicate()
print >> output_file
print >> output_file, cmd_output.stdout.read()
if mode == '\\retcode':
print >> output_file, '-- start_ignore'
print >> output_file, stdout
if mode == '\\retcode':
print >> output_file, '-- end_ignore'
print >> output_file, '(exited with code {})'.format(cmd_output.returncode)
else:
self.get_process(output_file, process_name, dbname=dbname).query(sql.strip())
elif flag == "&":
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册