# XXX Do this in Python in a thread?
sd_cmd = ''
if sys.executable:
- sd_cmd = sys.executable + ' '
+ sd_cmd = '"{}" '.format(sys.executable)
sd_cmd += os.path.join(config.this_dir, 'util_dump_dhcp_pcap.py ' + mode)
return sd_cmd
self.log_fname = self.filename_from_id('log')
# Our command line utilities generate UTF-8. The log file endcoding
# needs to match that.
- self.log_fd = io.open(self.log_fname, 'w', encoding='UTF-8')
+ # XXX newline='\n' works for now, but we might have to do more work
+ # to handle line endings in the future.
+ self.log_fd = io.open(self.log_fname, 'w', encoding='UTF-8', newline='\n')
self.cleanup_files.append(self.log_fname)
pre_run_problem_count = 0
if result:
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):
return True
def startProcess(self, proc_args, env=None, shell=False):
- '''Start a process in the background. Returns a subprocess.Popen object. You typically wait for it using waitProcess() or assertWaitProcess().'''
+ '''Start a process in the background. Returns a subprocess.Popen object.
+
+ You typically wait for it using waitProcess() or assertWaitProcess().'''
+ if env is None:
+ # Avoid using the test user's real environment by default.
+ env = config.test_env
proc = LoggingPopen(proc_args, env=env, shell=shell, log_fd=self.log_fd)
self.processes.append(proc)
return proc