potential fix
i cannot imagine how the while loop would go on forever, but hard limits are nice
This commit is contained in:
parent
01fcb60e31
commit
8470425d20
1 changed files with 13 additions and 6 deletions
|
@ -23,7 +23,6 @@ import datetime
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_timestamp():
|
def get_timestamp():
|
||||||
return datetime.datetime.fromtimestamp(time.time()).strftime("%Y.%m.%d-%H:%M:%S")
|
return datetime.datetime.fromtimestamp(time.time()).strftime("%Y.%m.%d-%H:%M:%S")
|
||||||
|
|
||||||
|
@ -93,13 +92,17 @@ def printerr(*args, **kwargs):
|
||||||
def removeNonAlphabetic(s):
|
def removeNonAlphabetic(s):
|
||||||
return "".join([i for i in s if i.isalpha()])
|
return "".join([i for i in s if i.isalpha()])
|
||||||
|
|
||||||
import pathlib
|
|
||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
|
||||||
def can_create_path(path_str: str):
|
def can_create_path(path_str: str):
|
||||||
path = pathlib.Path(path_str).absolute().resolve()
|
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 path.exists():
|
||||||
if os.access(path, os.W_OK):
|
if os.access(path, os.W_OK):
|
||||||
return True
|
return True
|
||||||
|
@ -111,7 +114,11 @@ def can_create_path(path_str : str):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
path = path.parent
|
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
|
# # Evaluate a bezier curve for the parameter 0<=t<=1 along its length
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue