]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
fanart: Tidy logging in Python script.
authorE.Smith <31170571+azlm8t@users.noreply.github.com>
Thu, 4 Oct 2018 17:07:33 +0000 (18:07 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 8 Oct 2018 12:01:16 +0000 (14:01 +0200)
We want to avoid logging stack traces unless the user explicitly
enables debug, otherwise we get tracebacks whenever user does
not specify an apikey for a module they do not wish to use
(but have not disabled).

lib/py/tvh/tv_meta_tmdb.py
lib/py/tvh/tv_meta_tvdb.py
support/tvhmeta

index f6597ffcd85e1bffb6c87b208782c21fa38fde2b..936b6277eb7223028b09204c88c00b6993fa469d 100755 (executable)
@@ -38,7 +38,7 @@ class Tv_meta_tmdb(object):
 
   def __init__(self, args):
       if args is None or "key" not in args or args["key"] is None or args["key"] == "":
-          logging.critical("Need a tmdb-key")
+          logging.critical("Need a tmdb-key. No lookup available with this module.")
           raise RuntimeError("Need a tmdb key");
       self.tmdb_key = args["key"]
       self.base_url = "https://api.themoviedb.org/3/" if 'base-url' not in args else args['base-url']
index 2643e98f0846927b2f54af7e020acf968f5f23db..59da74877317ef7c5cade65c3a0e518405814d16 100755 (executable)
@@ -54,7 +54,7 @@ Exceptions are thrown to indicate data could not be retrieved.
       logging.info(args)
       for arg in (["key"]):
           if args is None or arg not in args or args[arg] is None or args[arg] == "":
-              logging.critical("Need a tvdb-"  + arg)
+              logging.critical("Need a tvdb-"  + arg + ". No lookup available with this module.")
               raise RuntimeError("Need a tvdb-" + arg);
 
       self.languages = "en"
index 106a6e6336e0278268085f99f46990302cf4a426..898866a5cb7a644f0451621cefc557cda65d3927 100755 (executable)
@@ -35,6 +35,7 @@
 import urllib
 import logging
 import glob
+import traceback
 # Python3 decided to rename things and break compatibility...
 try:
   import urllib.parse
@@ -257,7 +258,7 @@ class TvhMeta(object):
                 obj = obj_fn(module_init_args)
                 client_objects[module] = obj
               except Exception as e:
-                logging.exception("Failed to import and create module %s: %s" % (module, e))
+                logging.info("Failed to import and create module %s: %s" % (module, e))
                 raise
             else:
               obj = client_objects[module]
@@ -282,15 +283,18 @@ class TvhMeta(object):
             else:
                 logging.info("Got poster %s and fanart %s so will try and get more artwork from other providers (if any)" % (poster, fanart))
           except Exception as e:
-            logging.info("Lookup failed for title %s year %s in language %s with error %s", title, year, lang, e)
+            # Only include a traceback in debug mode, otherwise it
+            # clutters the text if user runs it without api keys.
+            extraText = " with error " + traceback.format_exc() if logging.root.isEnabledFor(logging.DEBUG) else ""
+            logging.info("Lookup failed with module %s for uuid %s title %s year %s in language %s%s", module, uuid, title, year, lang, extraText)
             # And continue to next language
 
-    if art is None:
-        logging.error("Lookup completely failed for title %s year %s", title, year)
-        raise KeyError("Lookup completely failed for title %s year %s", title, year)
+    if poster is None and fanart is None:
+        logging.error("Lookup completely failed for uuid %s title %s year %s", uuid, title, year)
+        raise KeyError("Lookup completely failed for uuid {} title {} year {}".format(uuid, title, year))
 
     # Got map of fanart, poster
-    logging.info("Lookup success for title %s year %s with results %s", title, year, art)
+    logging.info("Lookup success for uuid %s title %s year %s with results poster: %s fanart: %s", uuid, title, year, poster, fanart)
     if poster is None and fanart is None:
         logging.info("No artwork found")
     else: