From 36cd765c215e49a2c7cc26f63621e065fa47832c Mon Sep 17 00:00:00 2001 From: Abby Gourlay Date: Sun, 8 Mar 2020 16:29:15 +0000 Subject: [PATCH] Updated debug logging for sanitising user data --- jellyfin_kodi/jellyfin/api.py | 4 ++-- jellyfin_kodi/jellyfin/connection_manager.py | 2 +- jellyfin_kodi/library.py | 25 +++++++++++++++++++- resources/settings.xml | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/jellyfin_kodi/jellyfin/api.py b/jellyfin_kodi/jellyfin/api.py index fbae8fc1..66442514 100644 --- a/jellyfin_kodi/jellyfin/api.py +++ b/jellyfin_kodi/jellyfin/api.py @@ -398,8 +398,8 @@ class API(object): if not settings('sslverify'): request_settings["verify"] = False - LOG.info("Sending %s request to %s" % (method, url)) - LOG.debug(request_settings) + LOG.info("Sending %s request to %s" % (method, path)) + LOG.debug(request_settings['timeout'], request_settings['headers']) return request_method(url, **request_settings) diff --git a/jellyfin_kodi/jellyfin/connection_manager.py b/jellyfin_kodi/jellyfin/connection_manager.py index afed1717..b1d76eee 100644 --- a/jellyfin_kodi/jellyfin/connection_manager.py +++ b/jellyfin_kodi/jellyfin/connection_manager.py @@ -173,6 +173,7 @@ class ConnectionManager(object): return { 'State': CONNECTION_STATE['Unavailable'] } def connect(self, options={}): + LOG.info("Begin connect") servers = self.get_available_servers() @@ -207,7 +208,6 @@ class ConnectionManager(object): return self.client.jellyfin.get_public_users() def _server_discovery(self): - MULTI_GROUP = ("", 7359) MESSAGE = b"who is JellyfinServer?" diff --git a/jellyfin_kodi/library.py b/jellyfin_kodi/library.py index 5ca1bdd9..790def45 100644 --- a/jellyfin_kodi/library.py +++ b/jellyfin_kodi/library.py @@ -127,6 +127,13 @@ class Library(threading.Thread): @stop() def service(self): + from kodi_six import xbmc, xbmcaddon + from datetime import datetime + path = xbmcaddon.Addon(id='plugin.video.jellyfin').getAddonInfo('path') + from pyinstrument import Profiler + + profiler = Profiler() + profiler.start() ''' If error is encountered, it will rerun this function. Start new "daemon threads" to process library updates. (actual daemon thread is not supported in Kodi) @@ -146,8 +153,17 @@ class Library(threading.Thread): self.worker_userdata() self.worker_remove() self.worker_notify() - + profiler.stop() + with open(str(path)+'/output-'+str(datetime.now())+'.html', 'w+') as output: + output.write(profiler.output_html().encode('utf-8')) if self.pending_refresh: + from kodi_six import xbmc, xbmcaddon + from datetime import datetime + path = xbmcaddon.Addon(id='plugin.video.jellyfin').getAddonInfo('path') + from pyinstrument import Profiler + + profiler = Profiler() + profiler.start() window('jellyfin_sync.bool', True) if self.total_updates > self.progress_display: @@ -169,6 +185,11 @@ class Library(threading.Thread): self.screensaver = get_screensaver() set_screensaver(value="") + profiler.stop() + with open(str(path)+'/output-'+str(datetime.now())+'.html', 'w+') as output: + output.write(profiler.output_html().encode('utf-8')) + + if (self.pending_refresh and not self.download_threads and not self.writer_threads['updated'] and not self.writer_threads['userdata'] and not self.writer_threads['removed']): self.pending_refresh = False self.save_last_sync() @@ -194,6 +215,8 @@ class Library(threading.Thread): if xbmc.getCondVisibility('Window.IsMedia'): xbmc.executebuiltin('Container.Refresh') + + def stop_client(self): self.stop_thread = True diff --git a/resources/settings.xml b/resources/settings.xml index 661da59b..7f1ff7f6 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -85,7 +85,7 @@ - +