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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## moler 4.3.1
* duplicates in ping

## moler 4.3.0
* Command Crrl+C
* Enhancement of MolerTimeout exception
Expand Down
1 change: 0 additions & 1 deletion moler/cmd/unix/ctrl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(self, connection, prompt=None, expected_prompt=None, newline_chars=
:param allowed_newline_after_prompt: If True then newline chars may occur after expected (target) prompt.
:param prompt_after_login: prompt after login before send export PS1. If you do not change prompt exporting PS1
then leave it None.
:param allowed_newline_after_prompt: If True, allows newline after prompt.
"""
super(CtrlC, self).__init__(connection=connection, prompt=prompt, expected_prompt=expected_prompt,
newline_chars=newline_chars, runner=runner,
Expand Down
4 changes: 3 additions & 1 deletion moler/cmd/unix/iperf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ def has_any_result(self) -> bool:
:return: True if current_ret has collected any data. Otherwise False.
"""

ret_value = False
if not self._output_parsed:
if '--version' in self.options:
was_version = any(self._regex_helper.search_compiled(Iperf2._re_version, line) for line in self.current_ret["INFO"])
Expand All @@ -644,7 +645,8 @@ def has_any_result(self) -> bool:
return was_version
else:
self._output_parsed = True # we don't exepect any specific data for this instance.
return super(Iperf2, self).has_any_result()
ret_value = super(Iperf2, self).has_any_result()
return ret_value


COMMAND_OUTPUT_version = """xyz@debian:~$ iperf --version
Expand Down
54 changes: 51 additions & 3 deletions moler/cmd/unix/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

__author__ = 'Julia Patacz, Marcin Usielski'
__copyright__ = 'Copyright (C) 2018-2024, Nokia'
__copyright__ = 'Copyright (C) 2018-2025, Nokia'
__email__ = '[email protected], [email protected]'

import re
Expand Down Expand Up @@ -106,9 +106,10 @@ def _parse_trans_recv_loss(self, line):
self.current_ret['time_seconds'] = None
raise ParsingDone

# 7 packets transmitted, 7 received, +6 duplicates, 0% packet loss, time 6142ms
# 4 packets transmitted, 3 received, +1 errors, 25% packet loss, time 3008ms
_re_trans_recv_loss_time_plus_errors = re.compile(
r"(?P<PKTS_TRANS>\d+) packets transmitted, (?P<PKTS_RECV>\d+) received, \+?(?P<ERRORS>\d+) errors, (?P<PKT_LOSS>\S+)% packet loss, time (?P<TIME>\d+)\s*(?P<UNIT>\w+)")
r"(?P<PKTS_TRANS>\d+) packets transmitted, (?P<PKTS_RECV>\d+) received, \+?(?P<ERR_DUP_VAL>\d+) (?P<ERR_DUP>errors|duplicates), (?P<PKT_LOSS>\S+)% packet loss, time (?P<TIME>\d+)\s*(?P<UNIT>\w+)")

def _parse_trans_recv_loss_time_plus_errors(self, line):
"""
Expand All @@ -121,7 +122,7 @@ def _parse_trans_recv_loss_time_plus_errors(self, line):
self._regex_helper.group('PKTS_TRANS'))
self.current_ret['packets_received'] = self._converter_helper.to_number(
self._regex_helper.group('PKTS_RECV'))
self.current_ret['errors'] = self._converter_helper.to_number(self._regex_helper.group('ERRORS'))
self.current_ret[self._regex_helper.group('ERR_DUP')] = self._converter_helper.to_number(self._regex_helper.group('ERR_DUP_VAL'))
self.current_ret['packet_loss'] = self._converter_helper.to_number(self._regex_helper.group('PKT_LOSS'))
self.current_ret['time'] = self._converter_helper.to_number(self._regex_helper.group('TIME'))
self.current_ret['packets_time_unit'] = self._regex_helper.group('UNIT')
Expand Down Expand Up @@ -431,3 +432,50 @@ def _parse_min_avg_max_mdev_unit_time(self, line):
'time_mdev_seconds': 0.000 * 0.001,
'time_unit': 'ms',
}


COMMAND_OUTPUT_duplicates = """ping 192.168.1.2 -c 7
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=254 time=0.297 ms
64 bytes from 192.168.1.2: icmp_seq=1 ttl=254 time=0.298 ms (DUP!)
64 bytes from 192.168.1.2: icmp_seq=2 ttl=254 time=0.291 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=254 time=0.291 ms (DUP!)
64 bytes from 192.168.1.2: icmp_seq=3 ttl=254 time=0.310 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=254 time=0.310 ms (DUP!)
64 bytes from 192.168.1.2: icmp_seq=4 ttl=254 time=0.282 ms
64 bytes from 192.168.1.2: icmp_seq=4 ttl=254 time=0.282 ms (DUP!)
64 bytes from 192.168.1.2: icmp_seq=5 ttl=254 time=0.356 ms
64 bytes from 192.168.1.2: icmp_seq=5 ttl=254 time=0.356 ms (DUP!)
64 bytes from 192.168.1.2: icmp_seq=6 ttl=254 time=0.286 ms
64 bytes from 192.168.1.2: icmp_seq=6 ttl=254 time=0.286 ms (DUP!)
64 bytes from 192.168.1.2: icmp_seq=7 ttl=254 time=0.327 ms

--- 192.168.1.2 ping statistics ---
7 packets transmitted, 7 received, +6 duplicates, 0% packet loss, time 6142ms
rtt min/avg/max/mdev = 0.282/0.305/0.356/0.024 ms
moler@moler:>"""


COMMAND_KWARGS_duplicates = {
'destination': '192.168.1.2',
'options': '-c 7'
}

COMMAND_RESULT_duplicates = {
'packets_transmitted': 7,
'packets_received': 7,
'packet_loss': 0,
'time': 6142,
'time_seconds': 6.142,
'packets_time_unit': 'ms',
'duplicates': 6,
'time_min': 0.282,
'time_avg': 0.305,
'time_max': 0.356,
'time_mdev': 0.024,
'time_min_seconds': 0.282 * 0.001,
'time_avg_seconds': 0.305 * 0.001,
'time_max_seconds': 0.356 * 0.001,
'time_mdev_seconds': 0.024 * 0.001,
'time_unit': 'ms',
}
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='moler',
version='4.3.0',
version='4.3.1',
description='Moler is a library for working with terminals, mainly for automated tests', # Required
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down