1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

ensure only one hyperglass directory exists

This commit is contained in:
checktheroads
2020-10-11 14:49:22 -07:00
parent fbb42e7c5b
commit 70e39102b0

View File

@@ -692,6 +692,13 @@ def set_app_path(required: bool = False) -> Path:
config_paths = (Path.home() / "hyperglass", Path("/etc/hyperglass/")) config_paths = (Path.home() / "hyperglass", Path("/etc/hyperglass/"))
# Ensure only one app directory exists to reduce confusion.
if all((p.exists() for p in config_paths)):
raise RuntimeError(
"Both '{}' and '{}' exist. ".format(*(p.as_posix() for p in config_paths))
+ "Please choose only one configuration directory and delete the other."
)
for path in config_paths: for path in config_paths:
try: try:
if path.exists(): if path.exists():
@@ -708,9 +715,9 @@ def set_app_path(required: bool = False) -> Path:
# Only raise an error if required is True # Only raise an error if required is True
raise RuntimeError( raise RuntimeError(
""" """
No configuration directories were determined to both exist and be readable No configuration directories were determined to both exist and be readable
by hyperglass. hyperglass is running as user '{un}' (UID '{uid}'), and tried by hyperglass. hyperglass is running as user '{un}' (UID '{uid}'), and tried
to access the following directories: to access the following directories:
{dir}""".format( {dir}""".format(
un=getuser(), un=getuser(),
uid=os.getuid(), uid=os.getuid(),