Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tcli/command_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def ParseCommandLine(self, line: str) -> tuple[str, list[str], bool]:
if not line:
raise ParseError('Missing escape command.')

# Expand command into command name, args and it it is append or not.
# Expand command into command name, args and if it is append or not.
command_name, line, append = self._CommandExpand(line)

if command_name not in self:
Expand Down
2 changes: 1 addition & 1 deletion tcli/command_parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def testParseCommandLine1(self):
'hoo the line is too long',
)

# Commnad with raw argument.
# Command with raw argument.
self.cmd_parser.RegisterCommand(
'foo', 'A help string.', short_name='F', raw_arg=True
)
Expand Down
2 changes: 1 addition & 1 deletion tcli/command_response_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def testGetRow(self):
self.cmd_response.InitCommandRow(1, 'testing')

# Two devices, so two responses for each of the two rows.
# Hence four requet IDs: 1-4.
# Hence four request IDs: 1-4.
self.cmd_response.SetRequest(1, 1)
self.cmd_response.SetRequest(1, 2)
# Responses for the first command have the higher IDs ... just because.
Expand Down
4 changes: 2 additions & 2 deletions tcli/inventory_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# Global vars so flags.FLAGS has inventroy intelligence in the main program.

# Maximum number of devices that can be the recipient of a command.
# Can (and should) be overriden in the child module or the command line.
# Can (and should) be overridden in the child module or the command line.
DEFAULT_MAXTARGETS = 50
# System default for what device targets to exclude from matching.
# Set this to avoid overly matching on devices that may rarely be an
Expand Down Expand Up @@ -741,7 +741,7 @@ def _BuildDeviceList(self) -> list[str]:
return self._device_list

def _AsyncLoad(self) -> None:
"""Wrapper for calling FetchDevices from withing a thread."""
"""Wrapper for calling FetchDevices from within a thread."""

try:
self._FetchDevices()
Expand Down
17 changes: 11 additions & 6 deletions tcli/tcli_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
short_name='t',
)


class Error(Exception):
"""Base class for errors."""

Expand Down Expand Up @@ -203,7 +204,7 @@ def __init__(
self.inventory.RegisterCommands(self.cli_parser)
command_register.RegisterCommands(self, self.cli_parser)
command_register.SetFlagDefaults(self.cli_parser)
# If interactive then the user will input furhter commands.
# If interactive then the user will input further commands.
# So we enable safe mode and apply the users .tclirc file.
if self.interactive:
# Set safe mode.
Expand All @@ -215,10 +216,7 @@ def __init__(

def __copy__(self) -> 'TCLI':
"""Copies attributes from self to new tcli object."""
inv_copy = (
copy.copy(self.inventory)
if self.inventory is not None else None
)
inv_copy = copy.copy(self.inventory) if self.inventory is not None else None
# Create new instance with existing inventory.
tcli_obj = type(self)(inv=inv_copy)
# TODO: Why does this break ParseCommands?
Expand Down Expand Up @@ -369,7 +367,14 @@ def _CmdRequests(

# Create command requests.
for device in device_list:
req = inventory.CmdRequest(device, command, self.mode)
# Site specific factory method for creating CmdRequest.
# Required if the CmdRequest needs device specific details.
if isinstance(self.inventory, inventory.Inventory) and hasattr(
self.inventory, 'CreateCmdRequest'
):
req = self.inventory.CreateCmdRequest(device, command, self.mode)
else:
req = inventory.CmdRequest(device, command, self.mode)
# Track the order that commands are submitted.
# Responses are received in any order and
# we use the row ID to reassemble.
Expand Down
10 changes: 5 additions & 5 deletions tcli/tcli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ def testCallback(self):

self.tcli_obj._FormatRow = mock.Mock()

# self.tcli_obj.Callback(
# inventory.Response(99, "device_name", "command", "data", "error"))
# # Test that nonexistant uid trigger early return.
# self.assertFalse(self.tcli_obj.cmd_response._response_count)
self.tcli_obj._Callback(
inventory.Response(99, "device_name", "command", "data", "error"))
# Test that nonexistent uid triggers an early return.
self.assertFalse(self.tcli_obj.cmd_response._response_count)

self.tcli_obj.cmd_response.InitCommandRow(0, '')
self.tcli_obj.cmd_response.InitCommandRow(1, '')
Expand Down Expand Up @@ -747,7 +747,7 @@ def testTCLIFilter(self):
"Invalid filter 'not_a_valid_filter'.", msgtype='warning'
)

def testTCLIBufferAsignment(self):
def testTCLIBufferAssignment(self):

# Ensure logging is clear
self.tcli_obj.record = ''
Expand Down
Loading