diff options
| author | tassaron | 2022-04-30 22:53:42 -0400 |
|---|---|---|
| committer | tassaron | 2022-04-30 22:53:42 -0400 |
| commit | 597da503cadbb1008e0cf15c37f570ad4d27c105 (patch) | |
| tree | 070fef4586ec95fe1918ce0c3899680e5aba4641 /src | |
| parent | a0d8e7bc0543aa9eb82d6d378ce6a8f5d0f85c11 (diff) | |
create test report in home folder after `--test`
Diffstat (limited to 'src')
| -rw-r--r-- | src/command.py | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/command.py b/src/command.py index cc13684..bf7941a 100644 --- a/src/command.py +++ b/src/command.py @@ -9,6 +9,7 @@ import os import sys import time import signal +import shutil import logging from . import core @@ -225,6 +226,38 @@ class Command(QtCore.QObject): from . import tests test_report = os.path.join(core.Core.logDir, "test_report.log") tests.run(test_report) + + # Print test report into terminal with open(test_report, "r") as f: output = f.readlines() - print("".join(output)) + test_output = "".join(output) + print(test_output) + + # Choose a numbered location to put the output file + logNumber = 0 + def getFilename(): + """Get a numbered filename for the final test report""" + nonlocal logNumber + name = os.path.join(os.path.expanduser('~'), "avp_test_report") + while True: + possibleName = f"{name}{logNumber:0>2}.txt" + if os.path.exists(possibleName) and logNumber < 100: + logNumber += 1 + continue + break + return possibleName + + # Copy latest debug log to chosen test report location + filename = getFilename() + if logNumber == 100: + print("Test Report could not be created.") + return + try: + shutil.copy(os.path.join(core.Core.logDir, "avp_debug.log"), filename) + except FileNotFoundError: + print("No debug log found.") + # Append actual test report to debug log + with open(filename, "a") as f: + f.write(f"{'='*59} debug log ends {'='*59}\n") + f.write(test_output) + print(f"Test Report created at {filename}") |
