summaryrefslogtreecommitdiffstats
path: root/core/utils.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2025-05-23 21:58:21 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2025-05-23 21:58:21 +0300
commit1bb950ec456a88ca43d5e2e4acefe94748326ee7 (patch)
tree1a2bd154d43527a4488d74e3f5049d386a57a4b7 /core/utils.py
parentc7df859d80368bf8c908097571948a47f7d45673 (diff)
downloadtroggle-1bb950ec456a88ca43d5e2e4acefe94748326ee7.tar.gz
troggle-1bb950ec456a88ca43d5e2e4acefe94748326ee7.tar.bz2
troggle-1bb950ec456a88ca43d5e2e4acefe94748326ee7.zip
initial method for identifying potato hut laptops as cookie
Diffstat (limited to 'core/utils.py')
-rw-r--r--core/utils.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/core/utils.py b/core/utils.py
index d86b901..3cb2d8a 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -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.