Skip to content

Commit

Permalink
Fixing NX-OS issue with double slashes and SCP (#1727)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers authored May 15, 2020
1 parent 3832f58 commit ef78483
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions netmiko/cisco/cisco_nxos_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ def remote_file_size(self, remote_cmd="", remote_file=None):
remote_cmd = f"dir {self.file_system}/{remote_file}"

remote_out = self.ssh_ctl_chan.send_command(remote_cmd)
if re.search("no such file or directory", remote_out, flags=re.I):
raise IOError("Unable to find file on remote system")
# Match line containing file name
escape_file_name = re.escape(remote_file)
pattern = r".*({}).*".format(escape_file_name)
match = re.search(pattern, remote_out)
if match:
file_size = match.group(0)
file_size = file_size.split()[0]

if "No such file or directory" in remote_out:
raise IOError("Unable to find file on remote system")
else:
return int(file_size)

raise IOError("Unable to find file on remote system")

@staticmethod
def process_md5(md5_output, pattern=r"= (.*)"):
"""Not needed on NX-OS."""
Expand Down
6 changes: 4 additions & 2 deletions netmiko/ssh_autodetect.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _send_command_wrapper(self, cmd):
return cached_results

def _autodetect_remote_version(
self, search_patterns=None, re_flags=re.I, priority=99
self, search_patterns=None, re_flags=re.IGNORECASE, priority=99
):
"""
Method to try auto-detect the device type, by matching a regular expression on the reported
Expand Down Expand Up @@ -350,7 +350,9 @@ def _autodetect_remote_version(
return 0
return 0

def _autodetect_std(self, cmd="", search_patterns=None, re_flags=re.I, priority=99):
def _autodetect_std(
self, cmd="", search_patterns=None, re_flags=re.IGNORECASE, priority=99
):
"""
Standard method to try to auto-detect the device type. This method will be called for each
device_type present in SSH_MAPPER_BASE dict ('dispatch' key). It will attempt to send a
Expand Down

0 comments on commit ef78483

Please sign in to comment.