summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortassaron2026-01-14 13:59:33 -0500
committertassaron2026-01-14 13:59:33 -0500
commit025db7a468f14405fb8d7ea6ab38f73b54a54feb (patch)
treea41d4ff88d8b0b9022b9951cc4c8a997a223a530
parent0d844e93b7091f3417ff87f960baabdd493f428a (diff)
rename `--test` and `--debug` args && add `--version` arg
-rw-r--r--src/avp/command.py42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/avp/command.py b/src/avp/command.py
index 783ac26..7f6f2d1 100644
--- a/src/avp/command.py
+++ b/src/avp/command.py
@@ -14,7 +14,7 @@ import signal
14import shutil 14import shutil
15import logging 15import logging
16 16
17from . import core 17from . import core, __version__
18 18
19 19
20log = logging.getLogger("AVP.Commandline") 20log = logging.getLogger("AVP.Commandline")
@@ -48,6 +48,10 @@ class Command(QtCore.QObject):
48 '-c 1 video "preset=My Logo" -c 2 vis layout=classic', 48 '-c 1 video "preset=My Logo" -c 2 vis layout=classic',
49 ) 49 )
50 50
51 parser.add_argument(
52 "--version", "-V", action="version", version=f"%(prog)s {__version__}"
53 )
54
51 # input/output automatic-export commands 55 # input/output automatic-export commands
52 parser.add_argument("-i", "--input", metavar="SOUND", help="input audio file") 56 parser.add_argument("-i", "--input", metavar="SOUND", help="input audio file")
53 parser.add_argument( 57 parser.add_argument(
@@ -62,12 +66,12 @@ class Command(QtCore.QObject):
62 # mutually exclusive debug options 66 # mutually exclusive debug options
63 debugCommands = parser.add_mutually_exclusive_group() 67 debugCommands = parser.add_mutually_exclusive_group()
64 debugCommands.add_argument( 68 debugCommands.add_argument(
65 "--test", 69 "--log",
66 action="store_true", 70 action="store_true",
67 help="run tests and create a report full of debugging info", 71 help="copy and shorten recent log files into ~/avp_log.txt",
68 ) 72 )
69 debugCommands.add_argument( 73 debugCommands.add_argument(
70 "--debug", 74 "--verbose", "-v",
71 action="store_true", 75 action="store_true",
72 help="create bigger logfiles while program is running", 76 help="create bigger logfiles while program is running",
73 ) 77 )
@@ -96,13 +100,13 @@ class Command(QtCore.QObject):
96 100
97 args = parser.parse_args() 101 args = parser.parse_args()
98 102
99 if args.debug: 103 if args.verbose:
100 core.FILE_LOGLVL = logging.DEBUG 104 core.FILE_LOGLVL = logging.DEBUG
101 core.STDOUT_LOGLVL = logging.DEBUG 105 core.STDOUT_LOGLVL = logging.DEBUG
102 core.Core.makeLogger() 106 core.Core.makeLogger()
103 107
104 if args.test: 108 if args.log:
105 self.runTests() 109 self.createLogFile()
106 quit(0) 110 quit(0)
107 111
108 if args.projpath: 112 if args.projpath:
@@ -170,8 +174,9 @@ class Command(QtCore.QObject):
170 elif ( 174 elif (
171 args.projpath is None 175 args.projpath is None
172 and "help" not in sys.argv 176 and "help" not in sys.argv
173 and "--debug" not in sys.argv 177 and "--verbose" not in sys.argv
174 and "--test" not in sys.argv 178 and "-v" not in sys.argv
179 and "--log" not in sys.argv
175 ): 180 ):
176 parser.print_help() 181 parser.print_help()
177 quit(1) 182 quit(1)
@@ -256,19 +261,14 @@ class Command(QtCore.QObject):
256 261
257 return None 262 return None
258 263
259 def runTests(self): 264 def createLogFile(self):
260 from . import tests
261
262 test_report = os.path.join(core.Core.logDir, "test_report.log")
263 tests.run(test_report)
264
265 # Choose a numbered location to put the output file 265 # Choose a numbered location to put the output file
266 logNumber = 0 266 logNumber = 0
267 267
268 def getFilename(): 268 def getFilename():
269 """Get a numbered filename for the final test report""" 269 """Get a numbered filename for the final test report"""
270 nonlocal logNumber 270 nonlocal logNumber
271 name = os.path.join(os.path.expanduser("~"), "avp_test_report") 271 name = os.path.join(os.path.expanduser("~"), "avp_log")
272 while True: 272 while True:
273 possibleName = f"{name}{logNumber:0>2}.txt" 273 possibleName = f"{name}{logNumber:0>2}.txt"
274 if os.path.exists(possibleName) and logNumber < 100: 274 if os.path.exists(possibleName) and logNumber < 100:
@@ -305,12 +305,4 @@ class Command(QtCore.QObject):
305 305
306 concatenateLogs("render_*.log") 306 concatenateLogs("render_*.log")
307 concatenateLogs("preview_*.log") 307 concatenateLogs("preview_*.log")
308 308 print(f"Log file created at {filename}")
309 # Append actual test report to debug log
310 with open(test_report, "r") as f:
311 output = f.readlines()
312 test_output = "".join(output)
313 print(test_output)
314 with open(filename, "a") as f:
315 f.write(test_output)
316 print(f"Test Report created at {filename}")