dotexe = '.exe'
for cmd in commands:
cmd_var = 'cmd_' + cmd
- cmd_path = os.path.join(path, cmd + dotexe)
+ cmd_path = os.path.normpath(os.path.join(path, cmd + dotexe))
if not os.path.exists(cmd_path) or not os.access(cmd_path, os.X_OK):
cmd_path = None
program_path = None
if capinfos_args is not None:
capinfos_cmd += capinfos_args
capinfos_cmd.append(cap_file)
- capinfos_stdout = str(subprocess.check_output(capinfos_cmd))
- self.log_fd_write_bytes(capinfos_stdout)
+ capinfos_data = subprocess.check_output(capinfos_cmd)
+ if sys.version_info[0] >= 3:
+ capinfos_stdout = capinfos_data.decode('UTF-8', 'replace')
+ else:
+ capinfos_stdout = unicode(capinfos_data, 'UTF-8', 'replace')
+ self.log_fd.write(capinfos_stdout)
return capinfos_stdout
def checkPacketCount(self, num_packets, cap_file=None):
}
capinfos_out = self.getCaptureInfo(capinfos_args=('-t', '-E', '-c', '-d', '-M'), cap_file=cap_file)
- for sp_key in str_pats:
- str_pat = '{}:\s+([\S ]+)'.format(str_pats[sp_key])
- str_res = re.search(str_pat, capinfos_out)
- self.assertTrue(str_res is not None, 'Failed to generate {}'.format(sp_key))
- cap_info[sp_key] = str_res.group(1)
-
- for ip_key in int_pats:
- int_pat = '{}:\s+(\d+)'.format(int_pats[ip_key])
- int_res = re.search(int_pat, capinfos_out)
- self.assertTrue(int_res is not None, 'Failed to generate {}'.format(ip_key))
- cap_info[ip_key] = int(int_res.group(1))
+ for ci_line in capinfos_out.splitlines():
+ for sp_key in str_pats:
+ str_pat = '{}:\s+([\S ]+)'.format(str_pats[sp_key])
+ str_res = re.search(str_pat, ci_line)
+ if str_res is not None:
+ cap_info[sp_key] = str_res.group(1)
+
+ for ip_key in int_pats:
+ int_pat = '{}:\s+(\d+)'.format(int_pats[ip_key])
+ int_res = re.search(int_pat, ci_line)
+ if int_res is not None:
+ cap_info[ip_key] = int(int_res.group(1))
return cap_info