def close(self): """Close the communication interface.""" self.obfs_client.stop() self.obfs_server.stop() self.commInterf.close() self.commInterf.terminate() self.shim_commInterf.close() self.shim_commInterf.terminate() if fu.is_pid_running(self.obfs_client): self.obfs_client.kill() if fu.is_pid_running(self.obfs_server): self.obfs_server.kill()
def close(self): """Close the communication interface.""" self.obfs_client.stop() self.obfs_server.stop() self.commInterf.close() self.commInterf.terminate() self.shim_commInterf.close() self.shim_commInterf.terminate() if fu.is_pid_running(self.obfs_client): self.obfs_client.kill() if fu.is_pid_running(self.obfs_server): self.obfs_server.kill()
def start_tor(self, datadir, args, stdout_loglevel=DEFAULT_TOR_LOGLEVEL, quiet=DEFAULT_TOR_LOG_QUIET): tor_proc_name = basename(datadir) pid_file = join(datadir, "pid") pid = fu.read_file(pid_file) if fu.is_pid_running(pid): log.debug( "TEST: {} process is already running.".format(tor_proc_name)) return int(pid) logfile = join(datadir, DEBUG_FNAME) fu.removedir(datadir) log.debug("TEST: Starting Tor {}".format(tor_proc_name)) log_args = [ "--DataDirectory", datadir, "--Log", "debug file {}".format(logfile), "--Log", "{} stdout".format(stdout_loglevel) ] if quiet: log_args += ["--quiet"] cmd = ["tor"] + args + log_args log.debug("COMMAND: {}".format(" ".join(cmd))) process = Popen(cmd) try: self.tor_log_watchdog(logfile) except gu.TimeExceededError: log.error("Attempt to run tor process has timedout!") self.tearDown() return fu.write_to_file(join(datadir, "pid"), str(process.pid)) log.debug("TEST: Finished loading {}".format(tor_proc_name)) return process.pid