Skip to content

Commit

Permalink
Fix deprecated regex format (#2763)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed Apr 27, 2022
1 parent 765f432 commit 4ed0c50
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions netmiko/juniper/juniper.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def enter_cli_mode(self) -> None:
return

def check_config_mode(
self, check_string: str = "]", pattern: str = r"(?m)[>#] $"
self, check_string: str = "]", pattern: str = r"(?m:[>#] $)"
) -> bool:
"""
Checks if the device is in configuration mode or not.
(?m) = Use multiline matching
?m = Use multiline matching
Juniper unfortunately will use # as a message indicator when not in config mode
For example, with commit confirmed.
Expand All @@ -84,13 +84,13 @@ def check_config_mode(
def config_mode(
self,
config_command: str = "configure",
pattern: str = r"(?s)Entering configuration mode.*\].*#",
pattern: str = r"(?s:Entering configuration mode.*\].*#)",
re_flags: int = 0,
) -> str:
"""
Enter configuration mode.
(?s) enables re.DOTALL in regex pattern.
?s = enables re.DOTALL in regex pattern.
"""
return super().config_mode(
config_command=config_command, pattern=pattern, re_flags=re_flags
Expand Down
9 changes: 9 additions & 0 deletions tests/test_juniper_junos/add_delay_juniper_junos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Add delay for cisco3; must be root or sudo to execute
sudo -s /sbin/tc qdisc del dev eth0 root
sudo -s /sbin/tc qdisc add dev eth0 root handle 1: prio
sudo -s /sbin/tc qdisc add dev eth0 parent 1:3 handle 30: tbf rate 20kbit buffer 1600 limit 3000
sudo -s /sbin/tc qdisc add dev eth0 parent 30:1 handle 31: netem delay 1000ms 10ms distribution normal loss 10%
sudo -s /sbin/tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 match ip dst 52.53.154.237 flowid 1:3

2 changes: 1 addition & 1 deletion tests/test_netmiko_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def test_clear_buffer(net_connect, commands, expected_responses):
enter = net_connect.RETURN
# Manually send a command down the channel so that data needs read.
net_connect.write_channel(f"{commands['basic']}{enter}")
time.sleep(1)
time.sleep(4)
net_connect.clear_buffer()
time.sleep(2)

Expand Down

0 comments on commit 4ed0c50

Please sign in to comment.