Merge branch 'master' into jesse/positional-arg

This commit is contained in:
Jesse Bannon 2023-03-02 22:45:53 -08:00
commit ce88613bd6
4 changed files with 7 additions and 4 deletions

View file

@ -136,6 +136,7 @@ def main() -> List[Tuple[Subscription, FileHandlerTransactionLog]]:
args, extra_args = parser.parse_known_args()
# Load the config
config: ConfigFile = ConfigFile.from_file_path(args.config).initialize()
transaction_logs: List[Tuple[Subscription, FileHandlerTransactionLog]] = []
@ -165,6 +166,4 @@ def main() -> List[Tuple[Subscription, FileHandlerTransactionLog]]:
transaction_log.to_output_message(subscription.output_directory),
)
# Ran successfully, so we can delete the debug file
Logger.cleanup(delete_debug_file=True)
return transaction_logs

View file

@ -4,6 +4,7 @@ from enum import Enum
from typing import List
from typing import Optional
from ytdl_sub import __local_version__
from ytdl_sub.utils.logger import LoggerLevels
@ -75,6 +76,7 @@ class MainArguments:
parser = argparse.ArgumentParser(
description="ytdl-sub: Automate download and adding metadata with YoutubeDL"
)
parser.add_argument("--version", action="version", version="%(prog)s " + __local_version__)
parser.add_argument(
MainArguments.CONFIG.short,
MainArguments.CONFIG.long,

View file

@ -27,6 +27,7 @@ def main():
logger = Logger.get()
try:
_main()
Logger.cleanup() # Ran successfully, so we can delete the debug file
except ValidationException as validation_exception:
logger.error(validation_exception)
sys.exit(1)

View file

@ -10,7 +10,7 @@ from ytdl_sub.utils.logger import LoggerLevels
def cleanup_debug_file():
Logger.set_log_level(log_level_name=LoggerLevels.DEBUG.name)
yield
Logger.cleanup(delete_debug_file=True)
Logger.cleanup()
class TestLogger:
@ -94,7 +94,8 @@ class TestLogger:
assert lines == ["[ytdl-sub:name_test] info test\n", "[ytdl-sub:name_test] debug test\n"]
Logger.cleanup(delete_debug_file=True)
# Ensure the file cleans up too
Logger.cleanup()
assert not os.path.isfile(Logger._DEBUG_LOGGER_FILE.name)
def test_logger_can_be_cleaned_during_execution(self):