MCPcopy Create free account
hub / github.com/apache/impala / do_rerun

Method do_rerun

shell/impala_shell/impala_shell.py:1728–1752  ·  view source on GitHub ↗

Rerun a command with an command index in history Example: @1;

(self, args)

Source from the content-addressed store, hash-verified

1726 print(READLINE_UNAVAILABLE_ERROR, file=sys.stderr)
1727
1728 def do_rerun(self, args):
1729 """Rerun a command with an command index in history
1730 Example: @1;
1731 """
1732 history_len = self.readline.get_current_history_length()
1733 # Rerun command shouldn't appear in history
1734 self.readline.remove_history_item(history_len - 1)
1735 history_len -= 1
1736 if not self.readline:
1737 print(READLINE_UNAVAILABLE_ERROR, file=sys.stderr)
1738 return CmdStatus.ERROR
1739 try:
1740 cmd_idx = int(args)
1741 except ValueError:
1742 print("Command index to be rerun must be an integer.", file=sys.stderr)
1743 return CmdStatus.ERROR
1744 if not (0 < cmd_idx <= history_len or -history_len <= cmd_idx < 0):
1745 print("Command index out of range. Valid range: [1, {0}] and [-{0}, -1]"
1746 .format(history_len), file=sys.stderr)
1747 return CmdStatus.ERROR
1748 if cmd_idx < 0:
1749 cmd_idx += history_len + 1
1750 cmd = self.readline.get_history_item(cmd_idx)
1751 print("Rerunning " + cmd, file=sys.stderr)
1752 return self.onecmd(cmd.rstrip(";"))
1753
1754 def do_tip(self, args):
1755 """Print a random tip"""

Callers

nothing calls this directly

Calls 2

onecmdMethod · 0.95
formatMethod · 0.45

Tested by

no test coverage detected