Skip to content

Commit

Permalink
Add geolocation not configured logging
Browse files Browse the repository at this point in the history
  • Loading branch information
zim514 committed Dec 30, 2023
1 parent 55b1209 commit 9571fcb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 67 deletions.
60 changes: 0 additions & 60 deletions .github/workflows/increment-version.yml

This file was deleted.

2 changes: 1 addition & 1 deletion script.service.hue/addon.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="1.5.2">
<addon id="script.service.hue" name="Hue Service" provider-name="zim514" version="1.5.3">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1"/>
Expand Down
5 changes: 5 additions & 0 deletions script.service.hue/resources/lib/hue.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def make_api_request(self, method, resource, discovery=False, **kwargs):
return 500
else:
xbmc.log(f"[script.service.hue] v2 make_request: HTTPError: {x}\nResponse: {x.response.text}")
reporting.process_exception(f"Response: {x.response.text}, Exception: {x}", logging=True)
return x.response.status_code
except (Timeout, json.JSONDecodeError) as x:
xbmc.log(f"[script.service.hue] v2 make_request: Timeout/JSONDecodeError: Response: {x.response.text}\n{x}")

Check notice on line 105 in script.service.hue/resources/lib/hue.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (124 \> 120 characters)

Check notice on line 105 in script.service.hue/resources/lib/hue.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (124 \> 120 characters)
Expand Down Expand Up @@ -313,6 +314,10 @@ def update_sunset(self):
geolocation = self.make_api_request("GET", "geolocation") # TODO: Support cases where geolocation is not configured on bridge.

Check notice on line 314 in script.service.hue/resources/lib/hue.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (135 \> 120 characters)

Check notice on line 314 in script.service.hue/resources/lib/hue.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (135 \> 120 characters)
xbmc.log(f"[script.service.hue] v2 update_sunset(): geolocation: {geolocation}")
sunset_str = self.search_dict(geolocation, "sunset_time")
if sunset_str is None:
reporting.process_exception(f"Sunset time not found in geolocation response: {geolocation}", logging=True)
return

self.sunset = convert_time(sunset_str)
xbmc.log(f"[script.service.hue] v2 update_sunset(): sunset: {self.sunset}")

Expand Down
17 changes: 11 additions & 6 deletions script.service.hue/resources/lib/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
from .language import get_string as _


def process_exception(exc, level="critical", error=""):
def process_exception(exc, level="critical", error="", logging=False):
xbmc.log(f"[script.service.hue] *** EXCEPTION ***: Type: {type(exc)},\n Exception: {exc},\n Error: {error},\n Traceback: {traceback.format_exc()}")

Check notice on line 21 in script.service.hue/resources/lib/reporting.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (152 \> 120 characters)

Check notice on line 21 in script.service.hue/resources/lib/reporting.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (152 \> 120 characters)
if ADDON.getSettingBool("error_reporting"):
if _error_report_dialog(exc):
_report_error(level, error, exc, logging)

'''

Check notice on line 26 in script.service.hue/resources/lib/reporting.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E305 expected 2 blank lines after class or function definition, found 1

Check notice on line 26 in script.service.hue/resources/lib/reporting.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E305 expected 2 blank lines after class or function definition, found 1
if exc is RequestException:
xbmc.log("[script.service.hue] RequestException, not reporting to rollbar")
notification(_("Hue Service"), _("Connection Error"), icon=xbmcgui.NOTIFICATION_ERROR)
else:
if ADDON.getSettingBool("error_reporting"):
if _error_report_dialog(exc):
_report_error(level, error, exc)
'''


def _error_report_dialog(exc):
Expand All @@ -38,7 +40,7 @@ def _error_report_dialog(exc):
return response


def _report_error(level="critical", error="", exc=""):
def _report_error(level="critical", error="", exc="", logging=False):
if any(val in ADDONVERSION for val in ["dev", "alpha", "beta"]):
env = "dev"
else:
Expand All @@ -52,4 +54,7 @@ def _report_error(level="critical", error="", exc=""):
'exc': exc
}
rollbar.init(ROLLBAR_API_KEY, capture_ip=False, code_version="v" + ADDONVERSION, root=ADDONPATH, scrub_fields='bridgeUser, bridgeIP, bridge_user, bridge_ip, server.host', environment=env)

Check notice on line 56 in script.service.hue/resources/lib/reporting.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (191 \> 120 characters)

Check notice on line 56 in script.service.hue/resources/lib/reporting.py

View workflow job for this annotation

GitHub Actions / Qodana for Python

PEP 8 coding style violation

PEP 8: E501 line too long (191 \> 120 characters)
rollbar.report_exc_info(sys.exc_info(), extra_data=data, level=level)
if logging:
rollbar.report_message(exc, extra_data=data, level=level)
else:
rollbar.report_exc_info(sys.exc_info(), extra_data=data, level=level)

0 comments on commit 9571fcb

Please sign in to comment.