def main():
options = parse_option()
initialize_cli(options)
if is_execute_tc_command(options.tc_command_output):
check_tc_command_installation()
is_delete_all = options.is_delete_all
else:
subprocrunner.SubprocessRunner.default_is_dry_run = True
is_delete_all = True
set_logger(False)
try:
verify_network_interface(options.device)
except NetworkInterfaceNotFoundError as e:
logger.error("{:s}: {}".format(e.__class__.__name__, e))
return errno.EINVAL
subprocrunner.SubprocessRunner.clear_history()
tc = create_tc_obj(options)
if options.log_level == logbook.INFO:
subprocrunner.set_log_level(logbook.ERROR)
normalize_tc_value(tc)
return_code = 0
if is_delete_all:
return_code = tc.delete_all_tc()
else:
return_code = tc.delete_tc()
command_history = "\n".join(tc.get_command_history())
if options.tc_command_output == TcCommandOutput.STDOUT:
print(command_history)
return return_code
elif options.tc_command_output == TcCommandOutput.SCRIPT:
set_logger(True)
write_tc_script(
Tc.Command.TCDEL, command_history, filename_suffix=options.device)
return return_code
logger.debug("command history\n{}".format(command_history))
return return_code
评论列表
文章目录