From 27868f942c8e1ba96a190abc470cf7c0e5cb3df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 22 Jan 2019 00:00:00 +0000 Subject: [PATCH] qemu-trace2txt: port to clifunction --- qemu-trace2txt | 38 ++++++++++++++++++++------------------ shell_helpers.py | 3 +++ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/qemu-trace2txt b/qemu-trace2txt index 46debb1..1e48514 100755 --- a/qemu-trace2txt +++ b/qemu-trace2txt @@ -1,27 +1,29 @@ #!/usr/bin/env python3 import os -import subprocess -import sys import common from shell_helpers import LF -def main(): - return self.sh.run_cmd( - [ - os.path.join(self.env['qemu_source_dir'], 'scripts/simpletrace.py'), LF, - os.path.join(self.env['qemu_build_dir'], 'trace-events-all'), LF, - os.path.join(self.env['qemu_trace_file']), LF, - ], - cmd_file=os.path.join(self.env['run_dir'], 'qemu-trace2txt'), - out_file=self.env['qemu_trace_txt_file'], - show_stdout=False, - ) +class Main(common.LkmcCliFunction): + def __init__(self): + super().__init__( + description='''\ +Convert a QEMU `-trace exec_tb` to text form. +''' + ) + + def timed_main(self): + return self.sh.run_cmd( + [ + os.path.join(self.env['qemu_source_dir'], 'scripts/simpletrace.py'), LF, + os.path.join(self.env['qemu_build_dir'], 'trace-events-all'), LF, + os.path.join(self.env['qemu_trace_file']), LF, + ], + cmd_file=os.path.join(self.env['run_dir'], 'qemu-trace2txt'), + out_file=self.env['qemu_trace_txt_file'], + show_stdout=False, + ) if __name__ == '__main__': - parser = self.get_argparse(argparse_args={ - 'description': 'Convert a QEMU `-trace exec_tb` to text form.' - }) - args = self.setup(parser) - sys.exit(main()) + Main().cli_exit() diff --git a/shell_helpers.py b/shell_helpers.py index 1d35e24..82345ae 100644 --- a/shell_helpers.py +++ b/shell_helpers.py @@ -169,6 +169,9 @@ class ShellHelpers: :param extra_env: extra environment variables to add when running the command :type extra_env: Dict[str,str] + + :return: exit status of the command + :rtype: int ''' if out_file is not None: stdout = subprocess.PIPE