From 8994b0671f1698cc834a42925282525ebd036fe6 Mon Sep 17 00:00:00 2001 From: Itay Mizeretz Date: Sun, 11 Nov 2018 20:03:17 +0200 Subject: [PATCH] fixed CR --- monkey/infection_monkey/network/tools.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/network/tools.py b/monkey/infection_monkey/network/tools.py index b3cd64d12..fa84f84fe 100644 --- a/monkey/infection_monkey/network/tools.py +++ b/monkey/infection_monkey/network/tools.py @@ -7,6 +7,8 @@ import struct import time import re +from six.moves import range + DEFAULT_TIMEOUT = 10 BANNER_READ = 1024 IP_ADDR_RE = r'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' @@ -240,8 +242,8 @@ def _traceroute_linux(target_ip, ttl): proc_obj = subprocess.Popen(cli, stdout=subprocess.PIPE) stdout, stderr = proc_obj.communicate() ips = re.findall(IP_ADDR_RE, stdout) - if len(ips) < 2: - raise Exception("Unexpected output") + if len(ips) < 2: # Unexpected output. Fail the whole thing since it's not reliable. + return [] elif ips[-1] in trace_list: # Failed getting this hop trace_list.append(None) else: