def onecmd_exec(self, line):
try:
if self.timing:
start_time = time.time()
result = cmd.Cmd.onecmd(self, line)
end_time = time.time()
print('took %.3f seconds' % (end_time - start_time))
return result
else:
return cmd.Cmd.onecmd(self, line)
except DeviceError as err:
print_err(err)
except ShellError as err:
print_err(err)
except SystemExit:
# When you use -h with argparse it winds up call sys.exit, which
# raises a SystemExit. We intercept it because we don't want to
# exit the shell, just the command.
return False
评论列表
文章目录