mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 14:21:27 +00:00
remove redundant code
This commit is contained in:
@@ -199,6 +199,32 @@ def validate_entrance_stations(ent=None):
|
|||||||
|
|
||||||
|
|
||||||
poslineregex = re.compile(r"^\(\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*)\s*\)\s*([^\s]+)$")
|
poslineregex = re.compile(r"^\(\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*),\s*([+-]?\d*\.\d*)\s*\)\s*([^\s]+)$")
|
||||||
|
# This regular expression matches a specific format:
|
||||||
|
# A tuple of three floating-point numbers, followed by a non-space string.
|
||||||
|
|
||||||
|
# Pattern breakdown:
|
||||||
|
# ^ : Start of string
|
||||||
|
# \( : Literal opening parenthesis
|
||||||
|
# \s* : Optional whitespace
|
||||||
|
# ([+-]?\d*\.\d*) : First float (with optional sign)
|
||||||
|
# ,\s* : Comma and optional whitespace
|
||||||
|
# ([+-]?\d*\.\d*) : Second float
|
||||||
|
# ,\s* : Comma and optional whitespace
|
||||||
|
# ([+-]?\d*\.\d*) : Third float
|
||||||
|
# \s*\) : Optional whitespace and closing parenthesis
|
||||||
|
# \s* : Optional whitespace after the tuple
|
||||||
|
# ([^\s]+) : Captures a non-space string (e.g. identifier, label)
|
||||||
|
# $ : End of string
|
||||||
|
|
||||||
|
# Example matches:
|
||||||
|
# "(1.23, -4.56, +7.89)SomeTextHere"
|
||||||
|
# "( 0.0 , 3.14 , 2.71 )ExtraStuff"
|
||||||
|
|
||||||
|
# Capturing groups returned:
|
||||||
|
# group(1): First float
|
||||||
|
# group(2): Second float
|
||||||
|
# group(3): Third float
|
||||||
|
# group(4): Trailing text (no spaces)
|
||||||
|
|
||||||
def LoadPositions():
|
def LoadPositions():
|
||||||
"""First load the survex stations for entrances and fixed points (about 600) into the database.
|
"""First load the survex stations for entrances and fixed points (about 600) into the database.
|
||||||
@@ -215,65 +241,65 @@ def LoadPositions():
|
|||||||
SurvexStation.objects.all().delete()
|
SurvexStation.objects.all().delete()
|
||||||
|
|
||||||
|
|
||||||
def runcavern3d(msg=None):
|
# def runcavern3d(msg=None):
|
||||||
if msg:
|
# if msg:
|
||||||
print(" - ", msg)
|
# print(" - ", msg)
|
||||||
outputdir = Path(str(f"{topdata}.svx")).parent
|
# outputdir = Path(str(f"{topdata}.svx")).parent
|
||||||
file3d = Path(f"{topdata}.3d")
|
# file3d = Path(f"{topdata}.3d")
|
||||||
try:
|
# try:
|
||||||
sp = subprocess.run(
|
# sp = subprocess.run(
|
||||||
[settings.CAVERN, "--log", f"--output={outputdir}", f"{topdata}.svx"],
|
# [settings.CAVERN, "--log", f"--output={outputdir}", f"{topdata}.svx"],
|
||||||
capture_output=True,
|
# capture_output=True,
|
||||||
check=False,
|
# check=False,
|
||||||
text=True,
|
# text=True,
|
||||||
) # check=False means exception not raised
|
# ) # check=False means exception not raised
|
||||||
if sp.returncode != 0:
|
# if sp.returncode != 0:
|
||||||
message = f" ! Error: cavern: creating {file3d} in runcavern3()"
|
# message = f" ! Error: cavern: creating {file3d} in runcavern3()"
|
||||||
stash_data_issue(parser="positions", message=message)
|
# stash_data_issue(parser="positions", message=message)
|
||||||
print(message)
|
# print(message)
|
||||||
|
|
||||||
# find the errors in the .log file
|
# # find the errors in the .log file
|
||||||
sp = subprocess.run(
|
# sp = subprocess.run(
|
||||||
["grep", "error:", f"{topdata}.log"], capture_output=True, check=False, text=True
|
# ["grep", "error:", f"{topdata}.log"], capture_output=True, check=False, text=True
|
||||||
) # check=False means exception not raised
|
# ) # check=False means exception not raised
|
||||||
message = f" ! Error: cavern: {sp.stdout} creating {file3d} "
|
# message = f" ! Error: cavern: {sp.stdout} creating {file3d} "
|
||||||
stash_data_issue(parser="positions", message=message)
|
# stash_data_issue(parser="positions", message=message)
|
||||||
print(message)
|
# print(message)
|
||||||
|
|
||||||
except:
|
# except:
|
||||||
message = f" ! CalledProcessError 'cavern' in runcavern3() at {topdata}."
|
# message = f" ! CalledProcessError 'cavern' in runcavern3() at {topdata}."
|
||||||
stash_data_issue(parser="positions", message=message)
|
# stash_data_issue(parser="positions", message=message)
|
||||||
print(message)
|
# print(message)
|
||||||
|
|
||||||
if file3d.is_file():
|
# if file3d.is_file():
|
||||||
message = f" ! CalledProcessError. File permissions {file3d.stat().st_mode} on {str(file3d)}"
|
# message = f" ! CalledProcessError. File permissions {file3d.stat().st_mode} on {str(file3d)}"
|
||||||
stash_data_issue(parser="positions", message=message)
|
# stash_data_issue(parser="positions", message=message)
|
||||||
print(message)
|
# print(message)
|
||||||
|
|
||||||
if file3d.is_file(): # might be an old one though, if previous step failed
|
# if file3d.is_file(): # might be an old one though, if previous step failed
|
||||||
try:
|
# try:
|
||||||
sp = subprocess.run(
|
# sp = subprocess.run(
|
||||||
[settings.SURVEXPORT, "--pos", f"{file3d}"],
|
# [settings.SURVEXPORT, "--pos", f"{file3d}"],
|
||||||
cwd=settings.SURVEX_DATA,
|
# cwd=settings.SURVEX_DATA,
|
||||||
capture_output=True,
|
# capture_output=True,
|
||||||
check=False,
|
# check=False,
|
||||||
text=True,
|
# text=True,
|
||||||
)
|
# )
|
||||||
if sp.returncode != 0:
|
# if sp.returncode != 0:
|
||||||
print(
|
# print(
|
||||||
f" ! Error: survexport creating {topdata}.pos in runcavern3().\n\n"
|
# f" ! Error: survexport creating {topdata}.pos in runcavern3().\n\n"
|
||||||
+ str(sp.stdout)
|
# + str(sp.stdout)
|
||||||
+ "\n\nreturn code: "
|
# + "\n\nreturn code: "
|
||||||
+ str(sp.returncode)
|
# + str(sp.returncode)
|
||||||
)
|
# )
|
||||||
except:
|
# except:
|
||||||
message = f" ! CalledProcessError 'survexport' in runcavern3() at {file3d}."
|
# message = f" ! CalledProcessError 'survexport' in runcavern3() at {file3d}."
|
||||||
stash_data_issue(parser="positions", message=message)
|
# stash_data_issue(parser="positions", message=message)
|
||||||
print(message)
|
# print(message)
|
||||||
else:
|
# else:
|
||||||
message = f" ! Failed to find {file3d} so aborting generation of new .pos, using old one if present"
|
# message = f" ! Failed to find {file3d} so aborting generation of new .pos, using old one if present"
|
||||||
stash_data_issue(parser="positions", message=message)
|
# stash_data_issue(parser="positions", message=message)
|
||||||
print(message)
|
# print(message)
|
||||||
|
|
||||||
topdata = Path(settings.SURVEX_DATA, settings.SURVEX_TOPNAME)
|
topdata = Path(settings.SURVEX_DATA, settings.SURVEX_TOPNAME)
|
||||||
print(f" - Generating a list of Pos from {topdata}.3d and then loading...")
|
print(f" - Generating a list of Pos from {topdata}.3d and then loading...")
|
||||||
|
|||||||
Reference in New Issue
Block a user