Changed pypaths to relative for cleaner tracebacks/filenames

This commit is contained in:
Eric Froemling 2020-05-07 01:33:28 -07:00
parent 85b01c72cc
commit 233a4a4f78
5 changed files with 22 additions and 45 deletions

View File

@ -4132,16 +4132,16 @@
"assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c", "assets/build/windows/x64/python.exe": "https://files.ballistica.net/cache/ba1/25/a7/dc87c1be41605eb6fefd0145144c",
"assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb", "assets/build/windows/x64/python37.dll": "https://files.ballistica.net/cache/ba1/b9/e4/d912f56e42e9991bcbb4c804cfcb",
"assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe", "assets/build/windows/x64/pythonw.exe": "https://files.ballistica.net/cache/ba1/6c/bb/b6f52c306aa4e88061510e96cefe",
"build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/10/99/352d39206f7d69fe6994cf76630f", "build/prefab/linux-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/eb/d0/41ac3000831997f7311ab1c12619",
"build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1b/5c/5d51f9311bea060aff1ba78badf2", "build/prefab/linux-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5e/34/501f1f0d214b0b71a83f8fc22096",
"build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/95/95/c3377070f58a64dbb0021a14c010", "build/prefab/linux/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/dc/6c/52b76d1e1d0202a0184860b9ff6e",
"build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/91/c2/9aa9ead87fe83ffc866b7eca2207", "build/prefab/linux/release/ballisticacore": "https://files.ballistica.net/cache/ba1/5b/45/989dfb31fe5af86bd43089e5181a",
"build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/15/f8/91f9155b210027bf2c502ed92b5c", "build/prefab/mac-server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/d5/2b/be060358811b7ea5108c18a12d9d",
"build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/ac/15/75f1062a7f6b72b5ef963a2b6526", "build/prefab/mac-server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/bd/f8/777aa2abf6debb13619d2d59bb25",
"build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/b4/6f/6079d00d0b6e431112353487fdce", "build/prefab/mac/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/a4/88/a2cf99e4c0813b76e1ac19b7a956",
"build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/b2/c0/22f3df76593e0fbc468e5798dae9", "build/prefab/mac/release/ballisticacore": "https://files.ballistica.net/cache/ba1/ed/86/249605f11e08d0211d198146d368",
"build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/29/28/cc1a0ce82174ae0f4c006e6bb703", "build/prefab/windows-server/debug/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/26/2b/cee80a566e95d637cecfd667e124",
"build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/56/64/e099012eb1cbe1db37b87b909933", "build/prefab/windows-server/release/dist/ballisticacore_headless.exe": "https://files.ballistica.net/cache/ba1/8a/23/40ae61cee91379aef206966d3de1",
"build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/55/3b/7774d86041fec2e13fa21576ced7", "build/prefab/windows/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/17/92/a8664301169a06904ed31c0f9648",
"build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/b1/db/7571aa0352b133e95a793f162a07" "build/prefab/windows/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/de/f4/3908b1cca896ddd96be9d339179f"
} }

View File

@ -34,7 +34,7 @@ NOTE: This file was autogenerated by gendummymodule; do not edit by hand.
""" """
# (hash we can use to see if this file is out of date) # (hash we can use to see if this file is out of date)
# SOURCES_HASH=286388262473216751526597126281034005544 # SOURCES_HASH=233656876767477563471907026700832716822
# I'm sorry Pylint. I know this file saddens you. Be strong. # I'm sorry Pylint. I know this file saddens you. Be strong.
# pylint: disable=useless-suppression # pylint: disable=useless-suppression

View File

@ -22,7 +22,6 @@
from __future__ import annotations from __future__ import annotations
import sys
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
import _ba import _ba
@ -123,19 +122,6 @@ class WidgetNotFoundError(NotFoundError):
""" """
def exc_str() -> str:
"""Returns a tidied up string for the current exception.
This performs some minor cleanup such as printing paths relative
to script dirs (full paths are often unwieldy in game installs).
"""
import traceback
excstr = traceback.format_exc()
for path in sys.path:
excstr = excstr.replace(path + '/', '')
return excstr
def print_exception(*args: Any, **keywds: Any) -> None: def print_exception(*args: Any, **keywds: Any) -> None:
"""Print info about an exception along with pertinent context state. """Print info about an exception along with pertinent context state.
@ -157,24 +143,18 @@ def print_exception(*args: Any, **keywds: Any) -> None:
if not _ba.do_once(): if not _ba.do_once():
return return
# Most tracebacks are gonna have ugly long install directories in them;
# lets strip those out when we can.
err_str = ' '.join([str(a) for a in args]) err_str = ' '.join([str(a) for a in args])
print('ERROR:', err_str) print('ERROR:', err_str)
_ba.print_context() _ba.print_context()
print('PRINTED-FROM:') print('PRINTED-FROM:')
# Basically the output of traceback.print_stack() slightly prettified: # Basically the output of traceback.print_stack()
stackstr = ''.join(traceback.format_stack()) stackstr = ''.join(traceback.format_stack())
for path in sys.path:
stackstr = stackstr.replace(path + '/', '')
print(stackstr, end='') print(stackstr, end='')
print('EXCEPTION:') print('EXCEPTION:')
# Basically the output of traceback.print_exc() slightly prettified: # Basically the output of traceback.print_exc()
excstr = traceback.format_exc() excstr = traceback.format_exc()
for path in sys.path:
excstr = excstr.replace(path + '/', '')
print('\n'.join(' ' + l for l in excstr.splitlines())) print('\n'.join(' ' + l for l in excstr.splitlines()))
except Exception: except Exception:
# I suppose using print_exception here would be a bad idea. # I suppose using print_exception here would be a bad idea.
@ -199,15 +179,11 @@ def print_error(err_str: str, once: bool = False) -> None:
if not _ba.do_once(): if not _ba.do_once():
return return
# Most tracebacks are gonna have ugly long install directories in them;
# lets strip those out when we can.
print('ERROR:', err_str) print('ERROR:', err_str)
_ba.print_context() _ba.print_context()
# Basically the output of traceback.print_stack() slightly prettified: # Basically the output of traceback.print_stack()
stackstr = ''.join(traceback.format_stack()) stackstr = ''.join(traceback.format_stack())
for path in sys.path:
stackstr = stackstr.replace(path + '/', '')
print(stackstr, end='') print(stackstr, end='')
except Exception: except Exception:
print('ERROR: exception in ba.print_error():') print('ERROR: exception in ba.print_error():')

View File

@ -162,9 +162,10 @@ class DirectoryScan:
try: try:
self.scan_module(moduledir, subpath) self.scan_module(moduledir, subpath)
except Exception: except Exception:
from ba import _error import traceback
self.results.warnings += ("Error scanning '" + str(subpath) + self.results.warnings += ("Error scanning '" + str(subpath) +
"': " + _error.exc_str() + '\n') "': " + traceback.format_exc() +
'\n')
def scan_module(self, moduledir: pathlib.Path, def scan_module(self, moduledir: pathlib.Path,
subpath: pathlib.Path) -> None: subpath: pathlib.Path) -> None:
@ -207,9 +208,9 @@ class DirectoryScan:
for submodule in submodules: for submodule in submodules:
self.scan_module(submodule[0], submodule[1]) self.scan_module(submodule[0], submodule[1])
except Exception: except Exception:
from ba import _error import traceback
self.results.warnings += ( self.results.warnings += (
f"Error scanning '{subpath}': {_error.exc_str()}\n") f"Error scanning '{subpath}': {traceback.format_exc()}\n")
def _process_module_meta_tags(self, subpath: pathlib.Path, def _process_module_meta_tags(self, subpath: pathlib.Path,
flines: List[str], flines: List[str],

View File

@ -1,5 +1,5 @@
<!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND --> <!-- THIS FILE IS AUTO GENERATED; DO NOT EDIT BY HAND -->
<h4><em>last updated on 2020-05-06 for Ballistica version 1.5.0 build 20011</em></h4> <h4><em>last updated on 2020-05-07 for Ballistica version 1.5.0 build 20015</em></h4>
<p>This page documents the Python classes and functions in the 'ba' module, <p>This page documents the Python classes and functions in the 'ba' module,
which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p> which are the ones most relevant to modding in Ballistica. If you come across something you feel should be included here or could be better explained, please <a href="mailto:support@froemling.net">let me know</a>. Happy modding!</p>
<hr> <hr>