diff --git a/src/tribler/core/components/libtorrent/download_manager/download_manager.py b/src/tribler/core/components/libtorrent/download_manager/download_manager.py index 0884f6967a4..d8d744ebe42 100644 --- a/src/tribler/core/components/libtorrent/download_manager/download_manager.py +++ b/src/tribler/core/components/libtorrent/download_manager/download_manager.py @@ -140,10 +140,9 @@ def convert_rate(rate: int) -> int: """ if rate == 0: return -1 - elif rate == -1: + if rate == -1: return 1 - else: - return rate * 1024 + return rate * 1024 @staticmethod def reverse_convert_rate(rate: int) -> int: @@ -153,10 +152,9 @@ def reverse_convert_rate(rate: int) -> int: """ if rate == -1: return 0 - elif rate == 1: + if rate == 1: return -1 - else: - return rate // 1024 + return rate // 1024 async def _check_dht_ready(self, min_dht_peers=60): """ diff --git a/src/tribler/core/components/libtorrent/tests/test_download_manager.py b/src/tribler/core/components/libtorrent/tests/test_download_manager.py index 18e3b625b84..db9aeddb4a5 100644 --- a/src/tribler/core/components/libtorrent/tests/test_download_manager.py +++ b/src/tribler/core/components/libtorrent/tests/test_download_manager.py @@ -274,6 +274,20 @@ async def test_start_download_existing_handle(fake_dlmgr): await download.shutdown() +def test_convert_rate(): + assert DownloadManager.convert_rate(0) == -1 # 0 is a special value + assert DownloadManager.convert_rate(-1) == 1 # -1 is a special value + for test_num in [1, 2, -2]: + assert DownloadManager.convert_rate(test_num) == test_num * 1024 + + +def test_reverse_convert_rate(): + assert DownloadManager.reverse_convert_rate(-1) == 0 # -1 is a special value + assert DownloadManager.reverse_convert_rate(1) == -1 # 1 is a special value + for test_num in [0, 2, -2]: + assert DownloadManager.reverse_convert_rate(test_num) == test_num // 1024 + + def test_start_download_existing_download(fake_dlmgr): """ Testing the addition of a torrent to the libtorrent manager, if there is a pre-existing download. diff --git a/src/tribler/gui/dialogs/feedbackdialog.py b/src/tribler/gui/dialogs/feedbackdialog.py index 9fb8a1d9aa8..7db0e9cfb15 100644 --- a/src/tribler/gui/dialogs/feedbackdialog.py +++ b/src/tribler/gui/dialogs/feedbackdialog.py @@ -170,34 +170,6 @@ def on_cancel_clicked(self, checked): def on_send_clicked(self, checked): self.send_report_button.setEnabled(False) self.send_report_button.setText(tr("SENDING...")) - sys_info = defaultdict(list) - for ind in range(self.env_variables_list.topLevelItemCount()): - item = self.env_variables_list.topLevelItem(ind) - key = item.text(0) - value = item.text(1) - - sys_info[key].append(value) - - # tags - self.additional_tags[VERSION] = self.tribler_version - self.additional_tags[MACHINE] = platform.machine() - self.additional_tags[OS] = platform.platform() - self.additional_tags[PLATFORM] = get_first_item(sys_info[PLATFORM]) - self.additional_tags[PLATFORM_DETAILS] = get_first_item(sys_info[PLATFORM_DETAILS]) - - # info - info = {} - - info['_error_text'] = self.reported_error.text - info['_error_long_text'] = self.reported_error.long_text - info['_error_context'] = self.reported_error.context - info[COMMENTS] = self.comments_text_edit.toPlainText() - info[SYSINFO] = sys_info - info[OS_ENVIRON] = sys_info[OS_ENVIRON] - delete_item(info[SYSINFO], OS_ENVIRON) - - info[ADDITIONAL_INFORMATION] = self.reported_error.additional_information - info[LAST_PROCESSES] = [str(p) for p in self.process_manager.get_last_processes()] self.sentry_reporter.send_event( event=self.reported_error.event,