From a8ce3a0d92784c7debf7fea26bf94faa21f707b3 Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Sat, 27 Feb 2021 22:56:49 -0500 Subject: [PATCH] added runtime --- modules/util.py | 4 +++- plex_meta_manager.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/util.py b/modules/util.py index e8f203cf..19b91596 100644 --- a/modules/util.py +++ b/modules/util.py @@ -679,7 +679,9 @@ def separator(text=None): logger.handlers[1].setFormatter(logging.Formatter(f"[%(asctime)s] %(filename)-27s %(levelname)-10s %(message)-{screen_width - 2}s")) logger.info(f"|{separating_character * screen_width}|") if text: - logger.info(f"| {get_centered_text(text)} |") + text_list = text.split("\n") + for t in text_list: + logger.info(f"| {get_centered_text(t)} |") logger.info(f"|{separating_character * screen_width}|") logger.handlers[0].setFormatter(logging.Formatter(f"| %(message)-{screen_width - 2}s |")) logger.handlers[1].setFormatter(logging.Formatter(f"[%(asctime)s] %(filename)-27s %(levelname)-10s | %(message)-{screen_width - 2}s |")) diff --git a/plex_meta_manager.py b/plex_meta_manager.py index 25e453cc..7341c605 100644 --- a/plex_meta_manager.py +++ b/plex_meta_manager.py @@ -1,4 +1,5 @@ -import argparse, logging, os, re, schedule, sys, time, datetime +import argparse, logging, os, re, schedule, sys, time +from datetime import datetime from modules import tests, util from modules.config import Config @@ -71,6 +72,7 @@ def start(config_path, test, daily, collections): elif test: start_type = "Test " elif collections: start_type = "Collections " else: start_type = "" + start_time = datetime.now() util.separator(f"Starting {start_type}Run") try: config = Config(default_dir, config_path) @@ -79,7 +81,7 @@ def start(config_path, test, daily, collections): util.print_stacktrace() logger.critical(e) logger.info("") - util.separator(f"Finished {start_type}Run") + util.separator(f"Finished {start_type}Run\nRun Time: {str(datetime.now() - start_time).split('.')[0]}") try: if args.run or args.test or args.collections: @@ -89,8 +91,8 @@ try: schedule.every().day.at(args.time).do(start, args.config, False, True, None) while True: schedule.run_pending() - current = datetime.datetime.now().strftime("%H:%M") - seconds = (datetime.datetime.strptime(args.time, "%H:%M") - datetime.datetime.strptime(current, "%H:%M")).total_seconds() + current = datetime.now().strftime("%H:%M") + seconds = (datetime.strptime(args.time, "%H:%M") - datetime.strptime(current, "%H:%M")).total_seconds() hours = int(seconds // 3600) if hours < 0: hours += 24