From 0ff499b50a83051f4837669662f11f958411f029 Mon Sep 17 00:00:00 2001 From: Jeppe Fihl-Pearson Date: Mon, 11 Dec 2023 20:54:10 +0000 Subject: [PATCH] Avoid throwing exception in case incorrect TV name was passed This instead outputs a nicer error message to the user. --- LGTV/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/LGTV/__init__.py b/LGTV/__init__.py index 46c634f..9ccfe54 100644 --- a/LGTV/__init__.py +++ b/LGTV/__init__.py @@ -172,6 +172,10 @@ def main(): print("A TV name is required. Set one with -n/--name or the setDefault command.") sys.exit(1) + if name not in config: + print(f"No entry with the name '{name}' was found in the configuration at {filename}.") + sys.exit(1) + if args.command == "sendButton": cursor = LGTVCursor(name, **config[name], ssl=args.ssl) cursor.connect()