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 + 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 - errpath = Path(fullpath + ".err") - if errpath.is_file(): - if errpath.stat().st_size == 0: - errpath.unlink() # delete empty closure error file + # 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)