mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 18:26:15 +00:00
remove the internal_exception.ExceptionWrapper class
This commit is contained in:
parent
4aef5d7551
commit
615e541513
8 changed files with 41 additions and 49 deletions
|
@ -24,7 +24,6 @@ import loghandler
|
||||||
from utils import window, dialog, language as lang
|
from utils import window, dialog, language as lang
|
||||||
from ga_client import GoogleAnalytics
|
from ga_client import GoogleAnalytics
|
||||||
import database
|
import database
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -162,10 +161,8 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Main()
|
Main()
|
||||||
except internal_exceptions.ExceptionWrapper as error:
|
|
||||||
log.exception(error)
|
|
||||||
raise
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
if not (hasattr(error, 'quiet') and error.quiet):
|
||||||
ga = GoogleAnalytics()
|
ga = GoogleAnalytics()
|
||||||
errStrings = ga.formatException()
|
errStrings = ga.formatException()
|
||||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
||||||
|
|
|
@ -11,7 +11,6 @@ import xbmcgui
|
||||||
import clientinfo
|
import clientinfo
|
||||||
import connect.connectionmanager as connectionmanager
|
import connect.connectionmanager as connectionmanager
|
||||||
from utils import window, settings, language as lang
|
from utils import window, settings, language as lang
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
@ -231,7 +230,9 @@ class DownloadUtils(object):
|
||||||
|
|
||||||
# does the URL look ok
|
# does the URL look ok
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
raise internal_exceptions.ExceptionWrapper("URL Error: " + url)
|
exc = Exception("URL Error: " + url)
|
||||||
|
exc.quiet = True
|
||||||
|
raise exc
|
||||||
|
|
||||||
##### PREPARE REQUEST #####
|
##### PREPARE REQUEST #####
|
||||||
kwargs.update({
|
kwargs.update({
|
||||||
|
@ -272,28 +273,33 @@ class DownloadUtils(object):
|
||||||
|
|
||||||
except requests.exceptions.SSLError as error:
|
except requests.exceptions.SSLError as error:
|
||||||
log.error("invalid SSL certificate for: %s", url)
|
log.error("invalid SSL certificate for: %s", url)
|
||||||
raise internal_exceptions.ExceptionWrapper(error)
|
error.quiet = True
|
||||||
|
raise
|
||||||
|
|
||||||
except requests.exceptions.ConnectTimeout as error:
|
except requests.exceptions.ConnectTimeout as error:
|
||||||
log.error("ConnectTimeout at: %s", url)
|
log.error("ConnectTimeout at: %s", url)
|
||||||
raise internal_exceptions.ExceptionWrapper(error)
|
error.quiet = True
|
||||||
|
raise
|
||||||
|
|
||||||
except requests.exceptions.ReadTimeout as error:
|
except requests.exceptions.ReadTimeout as error:
|
||||||
log.error("ReadTimeout at: %s", url)
|
log.error("ReadTimeout at: %s", url)
|
||||||
raise internal_exceptions.ExceptionWrapper(error)
|
error.quiet = True
|
||||||
|
raise
|
||||||
|
|
||||||
except requests.exceptions.ConnectionError as error:
|
except requests.exceptions.ConnectionError as error:
|
||||||
# Make the addon aware of status
|
# Make the addon aware of status
|
||||||
if window('emby_online') != "false":
|
if window('emby_online') != "false":
|
||||||
log.error("Server unreachable at: %s", url)
|
log.error("Server unreachable at: %s", url)
|
||||||
window('emby_online', value="false")
|
window('emby_online', value="false")
|
||||||
raise internal_exceptions.ExceptionWrapper(error)
|
error.quiet = True
|
||||||
|
raise
|
||||||
|
|
||||||
except requests.exceptions.HTTPError as error:
|
except requests.exceptions.HTTPError as error:
|
||||||
|
|
||||||
if response.status_code == 400:
|
if response.status_code == 400:
|
||||||
log.error("Malformed request: %s", error)
|
log.error("Malformed request: %s", error)
|
||||||
raise internal_exceptions.ExceptionWrapper(error)
|
error.quiet = True
|
||||||
|
raise
|
||||||
|
|
||||||
if response.status_code == 401:
|
if response.status_code == 401:
|
||||||
# Unauthorized
|
# Unauthorized
|
||||||
|
@ -309,12 +315,16 @@ class DownloadUtils(object):
|
||||||
icon=xbmcgui.NOTIFICATION_ERROR,
|
icon=xbmcgui.NOTIFICATION_ERROR,
|
||||||
time=5000)
|
time=5000)
|
||||||
window('emby_serverStatus', value="restricted")
|
window('emby_serverStatus', value="restricted")
|
||||||
raise internal_exceptions.ExceptionWrapper("restricted: " + str(error))
|
exc = Exception("restricted: " + str(error))
|
||||||
|
exc.quiet = True
|
||||||
|
raise exc
|
||||||
|
|
||||||
elif (response.headers['X-Application-Error-Code'] ==
|
elif (response.headers['X-Application-Error-Code'] ==
|
||||||
"UnauthorizedAccessException"):
|
"UnauthorizedAccessException"):
|
||||||
# User tried to do something his emby account doesn't allow
|
# User tried to do something his emby account doesn't allow
|
||||||
raise internal_exceptions.ExceptionWrapper("UnauthorizedAccessException: " + str(error))
|
exc = Exception("UnauthorizedAccessException: " + str(error))
|
||||||
|
exc.quiet = True
|
||||||
|
raise exc
|
||||||
|
|
||||||
elif status not in ("401", "Auth"):
|
elif status not in ("401", "Auth"):
|
||||||
# Tell userclient token has been revoked.
|
# Tell userclient token has been revoked.
|
||||||
|
@ -323,7 +333,9 @@ class DownloadUtils(object):
|
||||||
xbmcgui.Dialog().notification(heading="Error connecting",
|
xbmcgui.Dialog().notification(heading="Error connecting",
|
||||||
message="Unauthorized.",
|
message="Unauthorized.",
|
||||||
icon=xbmcgui.NOTIFICATION_ERROR)
|
icon=xbmcgui.NOTIFICATION_ERROR)
|
||||||
raise internal_exceptions.ExceptionWrapper("401: " + str(error))
|
exc = Exception("401: " + str(error))
|
||||||
|
exc.quiet = True
|
||||||
|
raise exc
|
||||||
|
|
||||||
except requests.exceptions.RequestException as error:
|
except requests.exceptions.RequestException as error:
|
||||||
log.error("unknown error connecting to: %s", url)
|
log.error("unknown error connecting to: %s", url)
|
||||||
|
|
|
@ -8,7 +8,6 @@ import hashlib
|
||||||
import xbmc
|
import xbmc
|
||||||
import time
|
import time
|
||||||
from utils import window, settings, language as lang
|
from utils import window, settings, language as lang
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
log = logging.getLogger("EMBY."+__name__)
|
log = logging.getLogger("EMBY."+__name__)
|
||||||
|
|
||||||
|
@ -23,12 +22,8 @@ def log_error(errors=(Exception, )):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except internal_exceptions.ExceptionWrapper as error:
|
|
||||||
log.exception(error)
|
|
||||||
log.error("log_error: %s \n args: %s \n kwargs: %s",
|
|
||||||
func.__name__, args, kwargs)
|
|
||||||
raise
|
|
||||||
except errors as error:
|
except errors as error:
|
||||||
|
if not (hasattr(error, 'quiet') and error.quiet):
|
||||||
ga = GoogleAnalytics()
|
ga = GoogleAnalytics()
|
||||||
errStrings = ga.formatException()
|
errStrings = ga.formatException()
|
||||||
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
|
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
|
|
||||||
# this is an internal exception wrapper that is used to raise exceptions
|
|
||||||
# when you dont want them logged ot the metric logging system
|
|
||||||
class ExceptionWrapper(Exception):
|
|
||||||
pass
|
|
|
@ -24,7 +24,6 @@ import views
|
||||||
from objects import Movies, MusicVideos, TVShows, Music
|
from objects import Movies, MusicVideos, TVShows, Music
|
||||||
from utils import window, settings, language as lang, should_stop
|
from utils import window, settings, language as lang, should_stop
|
||||||
from ga_client import GoogleAnalytics
|
from ga_client import GoogleAnalytics
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
@ -619,7 +618,7 @@ class LibrarySync(threading.Thread):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
ga = GoogleAnalytics()
|
ga = GoogleAnalytics()
|
||||||
errStrings = ga.formatException()
|
errStrings = ga.formatException()
|
||||||
if type(e) != internal_exceptions.ExceptionWrapper:
|
if not (hasattr(e, 'quiet') and e.quiet):
|
||||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
||||||
window('emby_dbScan', clear=True)
|
window('emby_dbScan', clear=True)
|
||||||
log.exception(e)
|
log.exception(e)
|
||||||
|
|
|
@ -15,7 +15,6 @@ import downloadutils
|
||||||
import read_embyserver as embyserver
|
import read_embyserver as embyserver
|
||||||
from ga_client import GoogleAnalytics
|
from ga_client import GoogleAnalytics
|
||||||
from utils import window, settings, dialog, language as lang, should_stop
|
from utils import window, settings, dialog, language as lang, should_stop
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
|
@ -30,12 +29,10 @@ def catch_except(errors=(Exception, ), default_value=False):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except internal_exceptions.ExceptionWrapper as error:
|
|
||||||
log.exception(error)
|
|
||||||
raise
|
|
||||||
except sqlite3.Error as error:
|
except sqlite3.Error as error:
|
||||||
raise
|
raise
|
||||||
except errors as error:
|
except errors as error:
|
||||||
|
if not (hasattr(error, 'quiet') and error.quiet):
|
||||||
errStrings = ga.formatException()
|
errStrings = ga.formatException()
|
||||||
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
|
ga.sendEventData("Exception", errStrings[0], errStrings[1], True)
|
||||||
log.exception(error)
|
log.exception(error)
|
||||||
|
|
|
@ -22,7 +22,6 @@ from views import VideoNodes
|
||||||
from utils import window, settings, dialog, language as lang
|
from utils import window, settings, dialog, language as lang
|
||||||
from ga_client import GoogleAnalytics
|
from ga_client import GoogleAnalytics
|
||||||
import hashlib
|
import hashlib
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -107,7 +106,9 @@ class Service(object):
|
||||||
# Profile change happened, terminate this thread and others
|
# Profile change happened, terminate this thread and others
|
||||||
log.info("Kodi profile was: %s and changed to: %s. Terminating old Emby thread.",
|
log.info("Kodi profile was: %s and changed to: %s. Terminating old Emby thread.",
|
||||||
kodi_profile, window('emby_kodiProfile'))
|
kodi_profile, window('emby_kodiProfile'))
|
||||||
raise internal_exceptions.ExceptionWrapper("Kodi profile changed detected")
|
exc = Exception("Kodi profile changed detected")
|
||||||
|
exc.quiet = True
|
||||||
|
raise exc
|
||||||
|
|
||||||
# Before proceeding, need to make sure:
|
# Before proceeding, need to make sure:
|
||||||
# 1. Server is online
|
# 1. Server is online
|
||||||
|
|
|
@ -22,7 +22,6 @@ import loghandler
|
||||||
from service_entry import Service
|
from service_entry import Service
|
||||||
from utils import settings
|
from utils import settings
|
||||||
from ga_client import GoogleAnalytics
|
from ga_client import GoogleAnalytics
|
||||||
import internal_exceptions
|
|
||||||
|
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
@ -42,11 +41,8 @@ if __name__ == "__main__":
|
||||||
raise RuntimeError("Abort event while waiting to start Emby for kodi")
|
raise RuntimeError("Abort event while waiting to start Emby for kodi")
|
||||||
# Start the service
|
# Start the service
|
||||||
service.service_entry_point()
|
service.service_entry_point()
|
||||||
except internal_exceptions.ExceptionWrapper as error:
|
|
||||||
log.exception(error)
|
|
||||||
log.info("Forcing shutdown")
|
|
||||||
service.shutdown()
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
if not (hasattr(error, 'quiet') and error.quiet):
|
||||||
ga = GoogleAnalytics()
|
ga = GoogleAnalytics()
|
||||||
errStrings = ga.formatException()
|
errStrings = ga.formatException()
|
||||||
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
ga.sendEventData("Exception", errStrings[0], errStrings[1])
|
||||||
|
|
Loading…
Reference in a new issue