print cli equivalent for commands called via python cli

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-01-22 00:00:00 +00:00
parent 869e0b2d17
commit b72f75b531
5 changed files with 158 additions and 55 deletions

View File

@@ -7,6 +7,7 @@ import copy
import datetime
import glob
import imp
import inspect
import json
import multiprocessing
import os
@@ -289,6 +290,17 @@ Use gem5 instead of QEMU. Shortcut for `--emulator gem5`.
'''
)
def __call__(self, **kwargs):
'''
For Python code calls, print the CLI equivalent of the call.
'''
print_cmd = ['./' + inspect.getfile(self.__class__), LF]
for line in self.get_cli(**kwargs):
print_cmd.extend(line)
print_cmd.append(LF)
shell_helpers.ShellHelpers.print_cmd(print_cmd)
return super().__call__(**kwargs)
def _init_env(self, env):
'''
Update the kwargs from the command line with values derived from them.
@@ -683,13 +695,14 @@ Use gem5 instead of QEMU. Shortcut for `--emulator gem5`.
'''
Time the main of the derived class.
'''
if not kwargs['dry_run']:
myargs = kwargs.copy()
if not myargs['dry_run']:
start_time = time.time()
kwargs.update(consts)
self._init_env(kwargs)
myargs.update(consts)
self._init_env(myargs)
self.sh = shell_helpers.ShellHelpers(dry_run=self.env['dry_run'])
ret = self.timed_main()
if not kwargs['dry_run']:
if not myargs['dry_run']:
end_time = time.time()
self._print_time(end_time - start_time)
return ret