initial method for identifying potato hut laptops as cookie

This commit is contained in:
2025-05-23 21:58:21 +03:00
parent c7df859d80
commit 1bb950ec45
3 changed files with 30 additions and 18 deletions

View File

@@ -283,7 +283,7 @@ def is_admin_user(user):
return False
if user.username in ["expoadmin"]:
return True
if user.is_superuser: # set in parsers/users.py i.e. WOokey, Philip S.
if user.is_superuser: # set in parsers/users.py i.e. Wookey, Philip S.
return True
return False
@@ -426,21 +426,24 @@ def write_binary_file(filepath, content):
write_files([(filepath, content, "")]) # null encoding does "wb"
def ensure_dir_exists(filepath):
if filepath.is_dir():
raise OSError(
f"CANNOT write this file {filepath} as this is an existing DIRECTORY."
)
try:
filepath.parent.mkdir(parents=True, exist_ok=True)
# os.makedirs(os.path.dirname(filepath), exist_ok = True)
except PermissionError as e:
raise PermissionError(
f"CANNOT make the directory.\nPERMISSIONS incorrectly set on server for this file {filepath}. Ask a nerd to fix this: {e}"
)
except Exception as e:
raise OSError(
f"CANNOT make the directory for {filepath}. Ask a nerd to fix this: {e}"
)
"""Takes a filepath for a file and all the parent directiories,
makes any directories necessary to make the filepath valid
"""
if filepath.is_dir():
raise OSError(
f"CANNOT write this file {filepath} as this is an existing DIRECTORY."
)
try:
filepath.parent.mkdir(parents=True, exist_ok=True)
# os.makedirs(os.path.dirname(filepath), exist_ok = True)
except PermissionError as e:
raise PermissionError(
f"CANNOT make the directory.\nPERMISSIONS incorrectly set on server for this file {filepath}. Ask a nerd to fix this: {e}"
)
except Exception as e:
raise OSError(
f"CANNOT make the directory for {filepath}. Ask a nerd to fix this: {e}"
)
def write_files(files):
for filepath, content, encoding in files:
@@ -528,6 +531,7 @@ def find_nearest_point(points, target_point):
TODO FIND OUT
1. is this SRTM data ? TICK. Yes.
2. what is the zero altitude datum? Geoid or ellisoid ? Do we need to subtract 47m ??
3. remove all these numbers from the .py file as it is confusing the code length calcs
In our dataset, the survey stations are all within 30m of an srtm reference point.
So we can safely ignore points more than 100m away in either x or y directions.