Various bugfixes
This commit is contained in:
parent
f2ce365c4b
commit
c7cf7b0c27
@ -39,6 +39,9 @@ export GURU_PYTHON_ROOT="$s_drive/$studio2023_path"
|
|||||||
export PYTHONPATH="$GURU_PYTHON_ROOT/env$pathsep$PYTHONPATH"
|
export PYTHONPATH="$GURU_PYTHON_ROOT/env$pathsep$PYTHONPATH"
|
||||||
export PYTHONPATH="$GURU_PYTHON_ROOT$pathsep$PYTHONPATH"
|
export PYTHONPATH="$GURU_PYTHON_ROOT$pathsep$PYTHONPATH"
|
||||||
|
|
||||||
|
# Remove anything from PYTHONPATH that contains Maya_Shared.
|
||||||
|
export PYTHONPATH=$(echo $PYTHONPATH | sed "s/[^$pathsep]*Maya_Shared[^$pathsep]*//g" | sed "s/$pathsep$pathsep/$pathsep/g" | sed "s/^$pathsep//g" | sed "s/$pathsep$//g")
|
||||||
|
|
||||||
# Update the PATH to point to the studio's install of python
|
# Update the PATH to point to the studio's install of python
|
||||||
if [ -d "/c/Programs/software/win/core/python/python_3.7.7" ]; then
|
if [ -d "/c/Programs/software/win/core/python/python_3.7.7" ]; then
|
||||||
export PATH="/c/Programs/software/win/core/python/python_3.7.7:$PATH"
|
export PATH="/c/Programs/software/win/core/python/python_3.7.7:$PATH"
|
||||||
|
30
scripts/pytb
30
scripts/pytb
@ -23,6 +23,7 @@ def main() -> int:
|
|||||||
ap.add_argument(
|
ap.add_argument(
|
||||||
"--no-strip-referer", help="Strip referer from flask tbs", action="store_true"
|
"--no-strip-referer", help="Strip referer from flask tbs", action="store_true"
|
||||||
)
|
)
|
||||||
|
ap.add_argument("--trace-only", help="Only print the trace", action="store_true")
|
||||||
ap.add_argument(
|
ap.add_argument(
|
||||||
"-v", "--verbose", help="Enable verbose logging", action="store_true"
|
"-v", "--verbose", help="Enable verbose logging", action="store_true"
|
||||||
)
|
)
|
||||||
@ -61,7 +62,7 @@ def main() -> int:
|
|||||||
frames = []
|
frames = []
|
||||||
is_in_frame = False
|
is_in_frame = False
|
||||||
for line in tb_lines[start_idx:]:
|
for line in tb_lines[start_idx:]:
|
||||||
if line.startswith("File "):
|
if line.lstrip().startswith("File "):
|
||||||
is_in_frame = True
|
is_in_frame = True
|
||||||
frames.append([line])
|
frames.append([line])
|
||||||
elif is_in_frame:
|
elif is_in_frame:
|
||||||
@ -90,28 +91,41 @@ def main() -> int:
|
|||||||
output_lines.append((statement, context))
|
output_lines.append((statement, context))
|
||||||
|
|
||||||
# Figure out the longest statement
|
# Figure out the longest statement
|
||||||
longest_statement = max(len(line[0]) for line in output_lines)
|
longest_statement = max(len(line[0]) for line in output_lines[:-1])
|
||||||
|
|
||||||
# Build the lines, padding the statements so that the files line up
|
# Build the lines, padding the statements so that the files line up
|
||||||
output = ""
|
output = ""
|
||||||
for statement, context in output_lines:
|
for statement, context in output_lines:
|
||||||
output += f"{statement.ljust(longest_statement)}{context}\n"
|
output += f"{statement.ljust(longest_statement)}{context}\n"
|
||||||
longest_line = max(len(line) for line in output.splitlines())
|
|
||||||
|
|
||||||
# remove any trailing newlines
|
# remove any trailing newlines
|
||||||
output = output.rstrip()
|
output = output.rstrip()
|
||||||
|
|
||||||
|
# Figure out the longest line
|
||||||
|
output_trace = "\n".join(output.splitlines()[:-1])
|
||||||
|
output_error = output.splitlines()[-1]
|
||||||
|
if args.trace_only:
|
||||||
|
longest_line = max(len(line) for line in output_trace.splitlines())
|
||||||
|
else:
|
||||||
|
longest_line = max(len(line) for line in output.splitlines())
|
||||||
|
|
||||||
# Pass over to rich to do the syntax highlighting
|
# Pass over to rich to do the syntax highlighting
|
||||||
console = Console(record=True, width=longest_line+1)
|
console = Console(record=True, width=longest_line + 1)
|
||||||
console.print(Syntax(output, "python", background_color="default"))
|
console.print(Syntax(output_trace, "python", background_color="default"))
|
||||||
|
if not args.trace_only:
|
||||||
|
console.print(
|
||||||
|
Syntax(output_error, "python", background_color="default")
|
||||||
|
)
|
||||||
|
|
||||||
# Export an image
|
# Export an image
|
||||||
file_name = f"Traceback {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
file_name = f"Traceback {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
|
||||||
if args.file:
|
if args.file:
|
||||||
file_name += f" ({args.file.stem})"
|
file_name += f" ({args.file.stem})"
|
||||||
file_name += ".svg"
|
file_name += ".svg"
|
||||||
OUTPUT_ROOT.mkdir(parents=True, exist_ok=True)
|
OUTPUT_ROOT.mkdir(parents=True, exist_ok=True)
|
||||||
console.save_svg(OUTPUT_ROOT / file_name, title="Evan's Python Traceback Visualizer")
|
console.save_svg(
|
||||||
|
OUTPUT_ROOT / file_name, title="Evan's Python Traceback Visualizer"
|
||||||
|
)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user