Skip to content

Commit

Permalink
Merge pull request #54 from tsbxmw/dev-2.2.0
Browse files Browse the repository at this point in the history
add command support in program: version/help/rerun
  • Loading branch information
tsbxmw authored Dec 20, 2018
2 parents 8405e13 + 5e1aea8 commit d9fe2e3
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
8 changes: 4 additions & 4 deletions haf/common/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ def connect_execute(self, sqlconfig:SQLConfig, sqlscript:list, **kwargs):
if isinstance(sqlscript, list):
for ss in sqlscript:
if ss != None and ss != "None" and "None" not in ss and len(ss) > 5:
logger.info(f"{key} start execute {ss}")
logger.info(f"{key} start {sqlconfig.host} execute {ss}")
cursor_m.execute(ss)
data.append(cursor_m.fetchall())
logger.info(f"{key} result {str(data)}")
elif isinstance(sqlscript, str):
if sqlscript != None and sqlscript != "None" and "None" not in sqlscript and len(sqlscript) > 5:
logger.info(f"{key} start execute {sqlscript}")
logger.info(f"{key} start {sqlconfig.host} execute {sqlscript}")
cursor_m.execute(sqlscript)
data.append(cursor_m.fetchall())
logger.info(f"{key} result {str(data)}")
Expand Down Expand Up @@ -135,13 +135,13 @@ def connect_execute(self, sqlconfig:SQLConfig, sqlscript:list, **kwargs):
if isinstance(sqlscript, list):
for ss in sqlscript:
if ss != None and ss != "None" and "None" not in ss and len(ss) > 5:
logger.info(f"{key} start execute {ss}")
logger.info(f"{key} [{sqlconfig.host}] start execute {ss}")
cursor_m.execute(ss)
data.append(cursor_m.fetchall())
logger.info(f"{key} result {str(data)}")
elif isinstance(sqlscript, str):
if sqlscript != None and sqlscript != "None" and "None" not in sqlscript and len(sqlscript) > 5:
logger.info(f"{key} start execute {sqlscript}")
logger.info(f"{key} start [{sqlconfig.host}] execute {sqlscript}")
cursor_m.execute(sqlscript)
data.append(cursor_m.fetchall())
logger.info(f"{key} result {str(data)}")
Expand Down
2 changes: 1 addition & 1 deletion haf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

MAIN_VERSION = 2
SUB_VERSION = 1
FIX_VERSION = 6
FIX_VERSION = 7
VERSION_TYPE = "dev"
PLATFORM_VERSION = f"{VERSION_TYPE}-{MAIN_VERSION}.{SUB_VERSION}.{FIX_VERSION}"

Expand Down
38 changes: 37 additions & 1 deletion haf/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def _start_web_server(self, args):

def run(self, args):
try:
self.args = args
self._init_logging_module(args)
self.case_name = Utils.get_case_name()
runner_count = args.runner_count if args.runner_count else 1
Expand Down Expand Up @@ -156,8 +157,43 @@ def wait_end_signal(self, args):
self.bus_client.get_system().put(SIGNAL_BUS_END)
break
time.sleep(0.1)
else:
cmd = input(f"haf-{PLATFORM_VERSION}# ")
self._run_cmd(cmd)
time.sleep(1)
except KeyboardInterrupt as key_inter:
self.bus_client.get_param().put(SIGNAL_STOP)


def _run_cmd(self, cmd):
if cmd == "rerun" or cmd == "r":
self._rerun()
elif cmd == "version" or cmd == "v":
self._version()
elif cmd == "help" or cmd == "h":
self._help()
else:
print("unsupported command!")
self._help()

def _rerun(self):
case_handler = self.bus_client.get_case()
while not case_handler.empty():
case_handler.get()
self._start_runner(self.args.runner_count if self.args.runner_count else 1, f"{self.args.log_dir}/{self.case_name}")
self._start_loader(1, self.bus_client)
self._start_recorder(1, self.args.report_output_dir, f"{self.args.log_dir}/{self.case_name}")
self.start_main()
self.put_loader_msg(self.args)
self.stop_main()

def _version(self):
print(BANNER_STRS)

def _help(self):
help = f"""
haf-{PLATFORM_VERSION}
# rerun / r rerun the input cases
# version / v version of haf
# help / h help information
"""
print(help)

0 comments on commit d9fe2e3

Please sign in to comment.