potential fix

i cannot imagine how the while loop would go on forever, but hard limits
are nice
This commit is contained in:
jrkb 2025-05-31 17:16:59 +02:00
parent 01fcb60e31
commit 8470425d20

View file

@ -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