Skip to content

Commit

Permalink
Simplifying structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Jan 19, 2019
1 parent b4f1e4f commit 0a2e7ff
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,25 +427,25 @@ def _file_prompt_quiet(f):

@functools.wraps(f)
def wrapper(self, *args, **kwargs):
# Only execute config change if allowed and not already done
if self.auto_file_prompt and self.prompt_quiet_changed is False:
# disable file operation prompts
self.device.send_config_set(["file prompt quiet"])
self.prompt_quiet_changed = True
self.prompt_quiet_configured = True
if not self.auto_file_prompt and not self.prompt_quiet_configured:
# check if the command is already in the running-config
cmd = "file prompt quiet"
show_cmd = "show running-config | inc {}".format(cmd)
output = self.device.send_command_expect(show_cmd)
if cmd in output:
if not self.prompt_quiet_configured:
if self.auto_file_prompt:
# disable file operation prompts
self.device.send_config_set(["file prompt quiet"])
self.prompt_quiet_changed = True
self.prompt_quiet_configured = True
else:
msg = (
"on-device file operations require prompts to be disabled. "
"Configure 'file prompt quiet' or set 'auto_file_prompt=True'"
)
raise CommandErrorException(msg)
# check if the command is already in the running-config
cmd = "file prompt quiet"
show_cmd = "show running-config | inc {}".format(cmd)
output = self.device.send_command_expect(show_cmd)
if cmd in output:
self.prompt_quiet_configured = True
else:
msg = (
"on-device file operations require prompts to be disabled. "
"Configure 'file prompt quiet' or set 'auto_file_prompt=True'"
)
raise CommandErrorException(msg)

# call wrapped function
return f(self, *args, **kwargs)
Expand Down

0 comments on commit 0a2e7ff

Please sign in to comment.