From 201acbb9bc7ff5113eda5b2e3275fdfb8f8d503b Mon Sep 17 00:00:00 2001 From: morpheus65535 <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 2 Oct 2018 10:28:47 -0400 Subject: [PATCH] More logging --- bazarr.py | 24 ++++++++++++++++-------- check_update.py | 2 ++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bazarr.py b/bazarr.py index 0e2f134a2..35d1a7fc6 100644 --- a/bazarr.py +++ b/bazarr.py @@ -222,7 +222,8 @@ def image_proxy(url): url_image = url_sonarr_short + '/' + url + '?apikey=' + apikey try: image_buffer = BytesIO(requests.get(url_sonarr + '/api' + url_image.split(url_sonarr)[1], timeout=15, verify=False).content) - except: + except Exception as e: + logging.exception('Unable to get image from Sonarr.') return None else: image_buffer.seek(0) @@ -1443,7 +1444,8 @@ def remove_subtitles(): os.remove(subtitlesPath) result = language_from_alpha3(language) + " subtitles deleted from disk." history_log(0, sonarrSeriesId, sonarrEpisodeId, result) - except OSError: + except OSError as e: + logging.exception('Error trying to delete file from disk.') pass store_subtitles(unicode(episodePath)) list_missing_subtitles(sonarrSeriesId) @@ -1462,7 +1464,8 @@ def remove_subtitles_movie(): os.remove(subtitlesPath) result = language_from_alpha3(language) + " subtitles deleted from disk." history_log_movie(0, radarrId, result) - except OSError: + except OSError as e: + logging.exception('Error trying to delete file from disk.') pass store_subtitles_movie(unicode(moviePath)) list_missing_subtitles_movies(radarrId) @@ -1493,7 +1496,8 @@ def get_subtitle(): store_subtitles(unicode(episodePath)) list_missing_subtitles(sonarrSeriesId) redirect(ref) - except OSError: + except OSError as e: + logging.exception('Error trying to save file to disk.') pass @route(base_url + 'manual_search', method='POST') @@ -1539,7 +1543,8 @@ def manual_get_subtitle(): store_subtitles(unicode(episodePath)) list_missing_subtitles(sonarrSeriesId) redirect(ref) - except OSError: + except OSError as e: + logging.exception('Error trying to save file to disk.') pass @route(base_url + 'get_subtitle_movie', method='POST') @@ -1566,7 +1571,8 @@ def get_subtitle_movie(): store_subtitles_movie(unicode(moviePath)) list_missing_subtitles_movies(radarrId) redirect(ref) - except OSError: + except OSError as e: + logging.exception('Error trying to save file to disk.') pass @route(base_url + 'manual_search_movie', method='POST') @@ -1611,7 +1617,8 @@ def manual_get_subtitle_movie(): store_subtitles_movie(unicode(moviePath)) list_missing_subtitles_movies(radarrId) redirect(ref) - except OSError: + except OSError as e: + logging.exception('Error trying to save file to disk.') pass def configured(): @@ -1658,7 +1665,8 @@ def api_history(): def test_url(protocol, url): try: result = requests.get(protocol + "://" + url, allow_redirects=False).json()['version'] - except: + except Exception as e: + logging.debug('BAZARR Unable to test this URL.') return dict(status=False) else: return dict(status=True, version=result) diff --git a/check_update.py b/check_update.py index 787c18956..701324bde 100644 --- a/check_update.py +++ b/check_update.py @@ -18,11 +18,13 @@ def gitconfig(): try: username = config_read.get_value("user", "name") except: + logging.debug('BAZARR Settings git username') config_write.set_value("user", "name", "Bazarr") try: email = config_read.get_value("user", "email") except: + logging.debug('BAZARR Settings git email') config_write.set_value("user", "email", "bazarr@fake.email") def check_and_apply_update():