Skip to content

Commit

Permalink
Move SenryMixin to the GUI package
Browse files Browse the repository at this point in the history
  • Loading branch information
drew2a committed Jan 3, 2022
1 parent 19aef13 commit f49671c
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 82 deletions.
20 changes: 0 additions & 20 deletions src/tribler-common/tribler_common/sentry_reporter/sentry_mixin.py

This file was deleted.

5 changes: 1 addition & 4 deletions src/tribler-gui/tribler_gui/dialogs/dialogcontainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QStyle, QStyleOption, QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.utilities import connect


class DialogContainer(AddBreadcrumbOnShowMixin, QWidget):
def __init__(self, parent, left_right_margin=100):
QWidget.__init__(self, parent)
self.set_sentry_reporter(gui_sentry_reporter)

self.setStyleSheet("background-color: rgba(30, 30, 30, 0.75);")

Expand Down
3 changes: 1 addition & 2 deletions src/tribler-gui/tribler_gui/dialogs/feedbackdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
from PyQt5.QtWidgets import QAction, QApplication, QDialog, QMessageBox, QTreeWidgetItem

from tribler_common.reported_error import ReportedError
from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_common.sentry_reporter.sentry_reporter import SentryReporter
from tribler_common.sentry_reporter.sentry_scrubber import SentryScrubber
from tribler_common.sentry_reporter.sentry_tools import CONTEXT_DELIMITER, LONG_TEXT_DELIMITER

from tribler_gui.event_request_manager import received_events
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_action_menu import TriblerActionMenu
from tribler_gui.tribler_request_manager import performed_requests as tribler_performed_requests
from tribler_gui.utilities import connect, get_ui_file_path, tr
Expand All @@ -33,7 +33,6 @@ def __init__( # pylint: disable=too-many-arguments, too-many-locals
retrieve_error_message_from_stacktrace=False,
):
QDialog.__init__(self, parent)
self.set_sentry_reporter(sentry_reporter)

uic.loadUi(get_ui_file_path('feedback_dialog.ui'), self)

Expand Down
12 changes: 12 additions & 0 deletions src/tribler-gui/tribler_gui/sentry_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from tribler_gui import gui_sentry_reporter


class AddBreadcrumbOnShowMixin:
"""This class has been designed for extending QWidget and QDialog instances
and send breadcrumbs on a show event.
"""

def showEvent(self, *args):
super().showEvent(*args)

gui_sentry_reporter.add_breadcrumb(message=f'{self.__class__.__name__}.Show', category='UI', level='info')
4 changes: 1 addition & 3 deletions src/tribler-gui/tribler_gui/widgets/channelcontentswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

from psutil import LINUX

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_common.simpledefs import CHANNEL_STATE

from tribler_core.components.metadata_store.db.orm_bindings.channel_node import DIRTY_STATUSES, NEW
from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT, COLLECTION_NODE

from tribler_gui import gui_sentry_reporter
from tribler_gui.defs import (
BUTTON_TYPE_CONFIRM,
BUTTON_TYPE_NORMAL,
Expand All @@ -22,6 +20,7 @@
)
from tribler_gui.dialogs.confirmationdialog import ConfirmationDialog
from tribler_gui.dialogs.new_channel_dialog import NewChannelDialog
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_action_menu import TriblerActionMenu
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import connect, disconnect, get_image_path, get_ui_file_path, tr
Expand All @@ -43,7 +42,6 @@
class ChannelContentsWidget(AddBreadcrumbOnShowMixin, widget_form, widget_class):
def __init__(self, parent=None):
widget_class.__init__(self, parent=parent)
self.set_sentry_reporter(gui_sentry_reporter)

# ACHTUNG! This is a dumb workaround for a bug(?) in PyQT bindings in Python 3.7
# When more than a single instance of a class is created, every next setupUi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
from PyQt5.QtNetwork import QNetworkRequest
from PyQt5.QtWidgets import QFileDialog, QPushButton

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.dialogs.confirmationdialog import ConfirmationDialog
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import connect, get_image_path, get_ui_file_path, tr

Expand Down Expand Up @@ -64,8 +62,6 @@ class ChannelDescriptionWidget(AddBreadcrumbOnShowMixin, widget_form, widget_cla

def __init__(self, parent=None):
widget_class.__init__(self, parent=parent)
self.set_sentry_reporter(gui_sentry_reporter)

try:
self.setupUi(self)
except SystemError:
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/createtorrentpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QAction, QFileDialog, QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.defs import BUTTON_TYPE_NORMAL, PAGE_EDIT_CHANNEL_TORRENTS
from tribler_gui.dialogs.confirmationdialog import ConfirmationDialog
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_action_menu import TriblerActionMenu
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import connect, get_image_path
Expand All @@ -21,8 +19,6 @@ class CreateTorrentPage(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.channel_identifier = None
self.dialog = None
self.selected_item_index = -1
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/discoveringpage.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from PyQt5.QtWidgets import QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.utilities import connect
from tribler_gui.widgets.loadingpage import LOADING_ANIMATION

Expand All @@ -15,8 +13,6 @@ class DiscoveringPage(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.found_channels = 0
self.is_discovering = False

Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/downloadspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
from PyQt5.QtNetwork import QNetworkRequest
from PyQt5.QtWidgets import QAbstractItemView, QAction, QFileDialog, QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.defs import (
BUTTON_TYPE_CONFIRM,
BUTTON_TYPE_NORMAL,
Expand All @@ -28,6 +25,7 @@
DOWNLOADS_FILTER_INACTIVE,
)
from tribler_gui.dialogs.confirmationdialog import ConfirmationDialog
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_action_menu import TriblerActionMenu
from tribler_gui.tribler_request_manager import TriblerFileDownloadRequest, TriblerNetworkRequest
from tribler_gui.utilities import compose_magnetlink, connect, format_speed, tr
Expand Down Expand Up @@ -55,8 +53,6 @@ class DownloadsPage(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.export_dir = None
self.filter = DOWNLOADS_FILTER_ALL
self.download_widgets = {} # key: infohash, value: QTreeWidgetItem
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/ipv8health.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.utilities import connect


Expand All @@ -29,8 +27,6 @@ class MonitorWidget(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
super().__init__()
self.set_sentry_reporter(gui_sentry_reporter)

self.is_paused = False

self.update_lock = threading.Lock()
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/loadingpage.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from PyQt5.QtSvg import QGraphicsSvgItem, QSvgRenderer
from PyQt5.QtWidgets import QGraphicsScene, QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.utilities import connect, get_image_path


Expand All @@ -29,8 +27,6 @@ class LoadingPage(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.loading_label = None
self.upgrading = False

Expand Down
5 changes: 1 addition & 4 deletions src/tribler-gui/tribler_gui/widgets/searchresultswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@

from PyQt5 import uic

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_common.utilities import Query, to_fts_query

from tribler_core.components.metadata_store.db.serialization import CHANNEL_TORRENT, COLLECTION_NODE, REGULAR_TORRENT

from tribler_gui import gui_sentry_reporter
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import connect, get_ui_file_path, tr
from tribler_gui.widgets.tablecontentmodel import SearchResultsModel
Expand Down Expand Up @@ -50,8 +49,6 @@ def complete(self):
class SearchResultsWidget(AddBreadcrumbOnShowMixin, widget_form, widget_class):
def __init__(self, parent=None):
widget_class.__init__(self, parent=parent)
self.set_sentry_reporter(gui_sentry_reporter)

self._logger = logging.getLogger(self.__class__.__name__)

try:
Expand Down
5 changes: 1 addition & 4 deletions src/tribler-gui/tribler_gui/widgets/settingspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from PyQt5.QtWidgets import QCheckBox, QFileDialog, QMessageBox, QSizePolicy, QWidget

from tribler_common.osutils import get_root_state_directory
from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_common.simpledefs import MAX_LIBTORRENT_RATE_LIMIT
from tribler_common.version_manager import remove_state_dirs

from tribler_gui import gui_sentry_reporter
from tribler_gui.defs import (
DARWIN,
DEFAULT_API_PORT,
Expand All @@ -21,6 +19,7 @@
PAGE_SETTINGS_SEEDING,
)
from tribler_gui.dialogs.confirmationdialog import ConfirmationDialog
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import (
AVAILABLE_TRANSLATIONS,
Expand All @@ -43,8 +42,6 @@ class SettingsPage(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.settings = None
self.version_history = None
self.lang_list = sorted([lang_name for lang_name, lang_code in AVAILABLE_TRANSLATIONS.items()])
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/subscriptionswidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QLabel, QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.utilities import connect, format_votes_rich_text, get_votes_rating_description, tr
from tribler_gui.widgets.tablecontentdelegate import DARWIN, WINDOWS

Expand All @@ -16,8 +14,6 @@ class SubscriptionsWidget(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self, parent):
QWidget.__init__(self, parent)
self.set_sentry_reporter(gui_sentry_reporter)

self.subscribe_button = None
self.initialized = False
self.contents_widget = None
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/trustgraphpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

import pyqtgraph as pg

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.defs import (
COLOR_DEFAULT,
COLOR_GREEN,
Expand All @@ -22,6 +19,7 @@
TB,
TRUST_GRAPH_PEER_LEGENDS,
)
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import connect, format_size, html_label, tr

Expand Down Expand Up @@ -84,8 +82,6 @@ def mouseDragEvent(self, event):
class TrustGraphPage(AddBreadcrumbOnShowMixin, QWidget):
def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.trust_graph = None
self.graph_view = None
self.selected_node = dict()
Expand Down
6 changes: 1 addition & 5 deletions src/tribler-gui/tribler_gui/widgets/trustpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

from PyQt5.QtWidgets import QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

from tribler_gui import gui_sentry_reporter
from tribler_gui.defs import PB, TB
from tribler_gui.dialogs.trustexplanationdialog import TrustExplanationDialog
from tribler_gui.sentry_mixin import AddBreadcrumbOnShowMixin
from tribler_gui.tribler_request_manager import TriblerNetworkRequest
from tribler_gui.utilities import connect
from tribler_gui.widgets.graphs.dataplot import TimeSeriesDataPlot
Expand All @@ -29,8 +27,6 @@ class TrustPage(AddBreadcrumbOnShowMixin, QWidget):

def __init__(self):
QWidget.__init__(self)
self.set_sentry_reporter(gui_sentry_reporter)

self.trust_plot = None
self.history = None
self.byte_scale = 1024 * 1024
Expand Down

0 comments on commit f49671c

Please sign in to comment.