summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-02-24 17:21:56 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2023-02-24 17:21:56 +0000
commitbc9306fc1b0f91d6612c678907f8b2c11f7c6d27 (patch)
treec7556893762f2458d5a565e644f1571dc6b202a6
parent4358e6440a625af61687f8a21d08985100a5428b (diff)
downloadtroggle-bc9306fc1b0f91d6612c678907f8b2c11f7c6d27.tar.gz
troggle-bc9306fc1b0f91d6612c678907f8b2c11f7c6d27.tar.bz2
troggle-bc9306fc1b0f91d6612c678907f8b2c11f7c6d27.zip
str() needed with python 3.11.0rc1 & added try/execept
-rw-r--r--parsers/survex.py69
1 files changed, 37 insertions, 32 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 1cb5eac..b88267a 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -1729,7 +1729,7 @@ class LoadingSurvex:
stash_data_issue(parser="survex", message=message, url=None, sb=(path))
return # skip this survex file and all things *included in it
except:
- message = f" ! ERROR *include file '{path}' in '{survexblock}' has unexpected error. OMITTED!"
+ message = f" ! ERROR *include file '{path}' in '{survexblock}' has unexpected error on opening file. OMITTED!"
print(message)
print(message, file=sys.stderr)
stash_data_issue(parser="survex", message=message, url=None, sb=(path))
@@ -1758,38 +1758,43 @@ class LoadingSurvex:
"""regenerates the .3d file from the .svx if it is older than the svx file, or older than the software,
or randomly using chaosmonkey() just to keep things ticking over.
"""
- print(
- f" - Regenerating stale (or chaos-monkeyed) cavern .log and .3d for '{fullpath}'\n at '{logpath}'\n"
- )
- print(
- f"days svx old: {(svx_t - log_t)/(24*3600):.1f} cav:{(cav_t - log_t)/(24*3600):.1f} log old: { (now - log_t)/(24*3600):.1f}"
- )
-
- outputdir = Path(str(f"{fullpath}.svx")).parent
- sp = subprocess.run(
- [settings.CAVERN, "--log", f"--output={outputdir}", f"{fullpath}.svx"],
- capture_output=True,
- check=False,
- text=True,
- )
- if sp.returncode != 0:
- message = f" ! Error running {settings.CAVERN}: {fullpath}"
- url = f"/survexfile{fullpath}.svx".replace(settings.SURVEX_DATA, "")
- stash_data_issue(parser="xEntrances", message=message, url=url)
- print(message)
+ try:
print(
- "stderr:\n\n" + str(sp.stderr) + "\n\n" + str(sp.stdout) + "\n\nreturn code: " + str(sp.returncode)
+ f" - Regenerating stale (or chaos-monkeyed) cavern .log and .3d for '{fullpath}'\n at '{logpath}'\n"
+ )
+ print(
+ f"days svx old: {(svx_t - log_t)/(24*3600):.1f} cav:{(cav_t - log_t)/(24*3600):.1f} log old: { (now - log_t)/(24*3600):.1f}"
)
- self.caverncount += 1
-
- # should also collect all the .err files too and create a DataIssue for each one which
- # - is nonzero in size AND
- # - has Error greater than 5% anywhere, or some other more serious error
- errpath = Path(fullpath + ".err")
- if errpath.is_file():
- if errpath.stat().st_size == 0:
- errpath.unlink() # delete empty closure error file
+ outputdir = Path(str(f"{fullpath}.svx")).parent
+ sp = subprocess.run(
+ [settings.CAVERN, "--log", f"--output={outputdir}", f"{fullpath}.svx"],
+ capture_output=True,
+ check=False,
+ text=True,
+ )
+ if sp.returncode != 0:
+ message = f" ! Error running {settings.CAVERN}: {fullpath}"
+ url = f"/survexfile{fullpath}.svx".replace(str(settings.SURVEX_DATA), "")
+ stash_data_issue(parser="xEntrances", message=message, url=url)
+ print(message)
+ print(
+ "stderr:\n\n" + str(sp.stderr) + "\n\n" + str(sp.stdout) + "\n\nreturn code: " + str(sp.returncode)
+ )
+ self.caverncount += 1
+
+ # should also collect all the .err files too and create a DataIssue for each one which
+ # - is nonzero in size AND
+ # - has Error greater than 5% anywhere, or some other more serious error
+
+ errpath = Path(fullpath + ".err")
+ if errpath.is_file():
+ if errpath.stat().st_size == 0:
+ errpath.unlink() # delete empty closure error file
+ except:
+ message = f' ! FAIL running cavern on survex file "{fullpath}" specified in *include in {calledpath} '
+ stash_data_issue(parser="survex", message=message)
+ print(message)
svxpath = Path(fullpath + ".svx")
logpath = Path(fullpath + ".log")
@@ -1797,7 +1802,7 @@ class LoadingSurvex:
if not svxpath.is_file():
message = f' ! BAD survex file "{fullpath}" specified in *include in {calledpath} '
- stash_data_issue(parser="entrances", message=message)
+ stash_data_issue(parser="survex", message=message)
print(message)
return
@@ -1811,7 +1816,7 @@ class LoadingSurvex:
sp = subprocess.run(["which", f"{settings.CAVERN}"], capture_output=True, check=False, text=True)
if sp.returncode != 0:
message = f' ! Error running "which" on {settings.CAVERN}'
- stash_data_issue(parser="entrances", message=message)
+ stash_data_issue(parser="survex", message=message)
print(message)
print(
"stderr:\n\n" + str(sp.stderr) + "\n\n" + str(sp.stdout) + "\n\nreturn code: " + str(sp.returncode)