From 8470425d20eed1f3da747e6fe7102fb9c5285c6f Mon Sep 17 00:00:00 2001 From: themancalledjakob Date: Sat, 31 May 2025 17:16:59 +0200 Subject: [PATCH] potential fix i cannot imagine how the while loop would go on forever, but hard limits are nice --- common/utils.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/common/utils.py b/common/utils.py index 77e4e8b..743b7cd 100644 --- a/common/utils.py +++ b/common/utils.py @@ -23,7 +23,6 @@ import datetime import time - def get_timestamp(): return datetime.datetime.fromtimestamp(time.time()).strftime("%Y.%m.%d-%H:%M:%S") @@ -93,13 +92,17 @@ def printerr(*args, **kwargs): def removeNonAlphabetic(s): return "".join([i for i in s if i.isalpha()]) -import pathlib -import os -def can_create_path(path_str : str): +import os +import pathlib + + +def can_create_path(path_str: str): path = pathlib.Path(path_str).absolute().resolve() - while True: # this looks dangerours, but it actually is not + tries = 0 + maximum_tries = 1000 + while True: if path.exists(): if os.access(path, os.W_OK): return True @@ -111,7 +114,11 @@ def can_create_path(path_str : str): return False path = path.parent - + tries += 1 + if tries > maximum_tries: + # always, always break out of while loops eventually + # IF you don't want to be here forever + break # # Evaluate a bezier curve for the parameter 0<=t<=1 along its length