Philipp Hörist pushed to branch master at gajim / gajim


Commits:
f3034862 by lovetox at 2022-04-16T15:48:02+02:00
chore: Bytestream: Add type annotations

- - - - -
e89cb1ab by lovetox at 2022-04-16T15:48:02+02:00
chore: Helpers: Add type annotations

- - - - -
26612aa8 by lovetox at 2022-04-16T15:48:02+02:00
fix: Exception: Make sure value is set for sentry payload

- - - - -


3 changed files:

- gajim/common/helpers.py
- gajim/common/modules/bytestream.py
- gajim/gtk/exception.py


Changes:

=====================================
gajim/common/helpers.py
=====================================
@@ -913,10 +913,10 @@ def timeout_wrapper():
     return delay_execution_decorator
 
 
-def event_filter(filter_):
-    def event_filter_decorator(func):
+def event_filter(filter_: Any):
+    def event_filter_decorator(func: Any) -> Any:
         @wraps(func)
-        def func_wrapper(self, event, *args, **kwargs):
+        def func_wrapper(self, event: Any, *args: Any, **kwargs: Any) -> Any:
             for attr in filter_:
                 if '=' in attr:
                     attr1, attr2 = attr.split('=')


=====================================
gajim/common/modules/bytestream.py
=====================================
@@ -43,7 +43,7 @@
 
 log = logging.getLogger('gajim.c.m.bytestream')
 
-def is_transfer_paused(file_props):
+def is_transfer_paused(file_props: FilesProp) -> bool:
     if file_props.stopped:
         return False
     if file_props.completed:
@@ -52,7 +52,7 @@ def is_transfer_paused(file_props):
         return False
     return file_props.paused
 
-def is_transfer_active(file_props):
+def is_transfer_active(file_props: FilesProp) -> bool:
     if file_props.stopped:
         return False
     if file_props.completed:
@@ -63,7 +63,7 @@ def is_transfer_active(file_props):
         return True
     return not file_props.paused
 
-def is_transfer_stopped(file_props):
+def is_transfer_stopped(file_props: FilesProp) -> bool:
     if not file_props:
         return True
     if file_props.error:


=====================================
gajim/gtk/exception.py
=====================================
@@ -229,7 +229,8 @@ def _init_sentry(self, endpoint: str) -> None:
             default_integrations=False,
             shutdown_timeout=0,
             auto_session_tracking=False,
-            before_send=self._before_send)
+            before_send=self._before_send,
+            debug=False)
 
         sentry_sdk.set_context('os', {
             'name': get_os_name(),
@@ -247,6 +248,16 @@ def _capture_exception(self) -> None:
         sentry_sdk.capture_exception(self._traceback_data)
 
     def _before_send(self, event: dict[str, Any], hint: Any) -> dict[str, Any]:
+        # Make sure the exception value is set, GitLab needs it.
+        # The value is the arg which is passed to the Exception.
+        # e.g. raise Exception('Error')
+        try:
+            value = event['exception']['values'][0].get('value')
+            if not value:
+                event['exception']['values'][0]['value'] = 'Unknown'
+        except Exception:
+            pass
+
         # Remove the hostname of the machine
         event['server_name'] = ''
         pprint.pprint(event)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/2bbd96644828c43def6c95555f33dfb011df1f5f...26612aa8e0b92eff9d58230a420d65c985f9c4ae

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/compare/2bbd96644828c43def6c95555f33dfb011df1f5f...26612aa8e0b92eff9d58230a420d65c985f9c4ae
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to