# Does the OS support all addresses in 127.0.0.0/8 without additional configuration?
_FULL_LOCALHOST_SUBNET = system() in ("Linux", "Windows")
# Does the OS support all addresses in 127.0.0.0/8 without additional configuration?
_FULL_LOCALHOST_SUBNET = system() in ("Linux", "Windows")
def _make_wd(name: str) -> str:
work_dir = os.path.join(path.TEST_WD, "data", name)
def _make_wd(name: str) -> str:
work_dir = os.path.join(path.TEST_WD, "data", name)
_port: T.Optional[int]
_scripts: T.Dict[str, TincScript]
_procs: T.List[subp.Popen]
_port: T.Optional[int]
_scripts: T.Dict[str, TincScript]
_procs: T.List[subp.Popen]
self.name = name if name else random_string(10)
self.address = addr if addr else _rand_localhost()
self._work_dir = _make_wd(self.name)
self.name = name if name else random_string(10)
self.address = addr if addr else _rand_localhost()
self._work_dir = _make_wd(self.name)
def read_port(self) -> int:
"""Read port used by tincd from its pidfile and update the _port field."""
def read_port(self) -> int:
"""Read port used by tincd from its pidfile and update the _port field."""
- _, _, _, token, port = content.split()
+ pid, _, _, token, port = content.split()
]
def sub(self, *paths: str) -> str:
"""Return path to a subdirectory within the working dir for this node."""
return os.path.join(self._work_dir, *paths)
]
def sub(self, *paths: str) -> str:
"""Return path to a subdirectory within the working dir for this node."""
return os.path.join(self._work_dir, *paths)
- self, *args: str, code: T.Optional[int] = 0, stdin: T.Optional[str] = None
+ self,
+ *args: str,
+ code: T.Optional[int] = 0,
+ stdin: T.Optional[T.AnyStr] = None,
+ timeout: T.Optional[int] = None,
) -> T.Tuple[str, str]:
"""Run command through tinc, writes `stdin` to it (if the argument is not None),
check its return code (if the argument is not None), and return (stdout, stderr).
"""
) -> T.Tuple[str, str]:
"""Run command through tinc, writes `stdin` to it (if the argument is not None),
check its return code (if the argument is not None), and return (stdout, stderr).
"""
log.debug('tinc %s: PID %d, in "%s", want code %s', self, proc.pid, stdin, code)
log.debug('tinc %s: PID %d, in "%s", want code %s', self, proc.pid, stdin, code)
res = proc.returncode
self._procs.remove(proc)
log.debug('tinc %s: code %d, out "%s", err "%s"', self, res, out, err)
res = proc.returncode
self._procs.remove(proc)
log.debug('tinc %s: code %d, out "%s", err "%s"', self, res, out, err)
"""Start tinc with the specified arguments."""
args = tuple(filter(bool, args))
cmd = [path.TINC_PATH, *self._common_args, *args]
"""Start tinc with the specified arguments."""
args = tuple(filter(bool, args))
cmd = [path.TINC_PATH, *self._common_args, *args]