projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert tincd path args to absolute paths
[tinc]
/
test
/
integration
/
testlib
/
util.py
diff --git
a/test/integration/testlib/util.py
b/test/integration/testlib/util.py
index
8102bca
..
f0849b9
100755
(executable)
--- a/
test/integration/testlib/util.py
+++ b/
test/integration/testlib/util.py
@@
-7,6
+7,7
@@
import random
import string
import socket
import typing as T
import string
import socket
import typing as T
+from pathlib import Path
from . import check
from .log import log
from . import check
from .log import log
@@
-31,6
+32,15
@@
def random_port() -> int:
log.debug("could not bind to random port %d", port, exc_info=ex)
log.debug("could not bind to random port %d", port, exc_info=ex)
+def remove_file(path: T.Union[str, Path]) -> bool:
+ """Try to remove file without failing if it does not exist."""
+ try:
+ os.remove(path)
+ return True
+ except FileNotFoundError:
+ return False
+
+
def random_string(k: int) -> str:
"""Generate a random alphanumeric string of length k."""
return "".join(random.choices(_ALPHA_NUMERIC, k=k))
def random_string(k: int) -> str:
"""Generate a random alphanumeric string of length k."""
return "".join(random.choices(_ALPHA_NUMERIC, k=k))