Fix intermittent installation/update failures
Some checks failed
Build JellyCon / build (py2) (push) Has been cancelled
Build JellyCon / build (py3) (push) Has been cancelled
CodeQL Analysis / analyze (python, 3.9) (push) Has been cancelled
Release Drafter / Update release draft (push) Has been cancelled
Test JellyCon / test (3.9) (push) Has been cancelled

Add exception handling for addon and settings initialization during
installation/update when addon may not be fully registered yet:
- Wrap __addon__ and __pluginpath__ initialization in try/except
- Handle settings access failures in LogHandler.__init__()
- Protect formatException() and _gen_rel_path() from missing __pluginpath__
This commit is contained in:
mani
2026-01-06 01:07:20 +01:00
parent 7d6ee45263
commit 1879a8ed01

View File

@@ -12,8 +12,13 @@ from kodi_six import xbmc, xbmcaddon
from .utils import translate_path
__addon__ = xbmcaddon.Addon(id='plugin.video.jellycon')
__pluginpath__ = translate_path(__addon__.getAddonInfo('path'))
try:
__addon__ = xbmcaddon.Addon(id='plugin.video.jellycon')
__pluginpath__ = translate_path(__addon__.getAddonInfo('path'))
except Exception:
# During installation/update, addon might not be fully registered yet
__addon__ = None
__pluginpath__ = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
def getLogger(name=None):
@@ -32,9 +37,14 @@ class LogHandler(logging.StreamHandler):
self.sensitive = {'Token': [], 'Server': []}
settings = xbmcaddon.Addon()
self.server = settings.getSetting('server_address')
self.debug = settings.getSetting('log_debug')
try:
settings = xbmcaddon.Addon()
self.server = settings.getSetting('server_address')
self.debug = settings.getSetting('log_debug')
except Exception:
# During installation/update, settings might not be available yet
self.server = ''
self.debug = 'false'
def emit(self, record):
@@ -96,13 +106,16 @@ class MyFormatter(logging.Formatter):
return result
def formatException(self, exc_info):
_pluginpath_real = os.path.realpath(__pluginpath__)
try:
_pluginpath_real = os.path.realpath(__pluginpath__)
except Exception:
_pluginpath_real = None
res = []
for o in traceback.format_exception(*exc_info):
o = ensure_text(o, get_filesystem_encoding())
if o.startswith(' File "'):
if _pluginpath_real and o.startswith(' File "'):
"""
If this split can't handle your file names,
you should seriously consider renaming your files.
@@ -118,7 +131,10 @@ class MyFormatter(logging.Formatter):
def _gen_rel_path(self, record):
if record.pathname:
record.relpath = os.path.relpath(record.pathname, __pluginpath__)
try:
record.relpath = os.path.relpath(record.pathname, __pluginpath__)
except Exception:
record.relpath = record.pathname
def get_filesystem_encoding():