From 0819fd40886cf173c2545e819be8795db800a9b5 Mon Sep 17 00:00:00 2001 From: emdee Date: Wed, 26 Oct 2022 09:01:50 +0000 Subject: [PATCH] Fixes --- toxygen/app.py | 22 ++++++++++++++++++---- toxygen/bootstrap/bootstrap.py | 1 + toxygen/contacts/group_chat.py | 1 - toxygen/middleware/threads.py | 2 +- toxygen/middleware/tox_factory.py | 5 +++-- toxygen/ui/main_screen.py | 2 +- toxygen/ui/peer_screen.py | 8 +++++--- toxygen/user_data/settings.py | 4 ++-- 8 files changed, 31 insertions(+), 14 deletions(-) diff --git a/toxygen/app.py b/toxygen/app.py index 97b9978..20510e3 100644 --- a/toxygen/app.py +++ b/toxygen/app.py @@ -886,13 +886,25 @@ class App: else: LOG.debug("Have default route for network " +self._oArgs.network) - LOG.debug(f"test_net {self._oArgs.network} iMax= {iMax}") + lUdpElts = self._settings['current_nodes_udp'] + if self._oArgs.proxy_type <= 0 and not lUdpElts: + title = 'test_net Error' + text = 'Error: ' + str('No UDP nodes') + util_ui.message_box(text, title) + return + lTcpElts = self._settings['current_nodes_tcp'] + if self._oArgs.proxy_type > 0 and not lTcpElts: + title = 'test_net Error' + text = 'Error: ' + str('No TCP nodes') + util_ui.message_box(text, title) + return + LOG.debug(f"test_net {self._oArgs.network} lenU={len(lUdpElts)} lenT={len(lTcpElts)} iMax= {iMax}") i = 0 while i < iMax: # if oThread and oThread._stop_thread: return i = i + 1 LOG.debug(f"bootstrapping status # {i}") - self._test_bootstrap(self._settings['current_nodes_udp']) + self._test_bootstrap(lUdpElts) if hasattr(self._oArgs, 'proxy_type') and self._oArgs.proxy_type > 0: LOG.debug(f"relaying status # {i}") self._test_relays(self._settings['current_nodes_tcp']) @@ -930,9 +942,11 @@ class App: def _test_bootstrap(self, lElts=None): if lElts is None: lElts = self._settings['current_nodes_udp'] - shuffle(lElts) LOG.debug(f"_test_bootstrap #Elts={len(lElts)}") - ts.bootstrap_good(lElts[:iNODES], [self._tox]) + if not lElts: + return + shuffle(lElts) + ts.bootstrap_udp(lElts[:iNODES], [self._tox]) LOG.info("Connected status: " +repr(self._tox.self_get_connection_status())) def _test_relays(self, lElts=None): diff --git a/toxygen/bootstrap/bootstrap.py b/toxygen/bootstrap/bootstrap.py index 7df3eb1..f80618b 100644 --- a/toxygen/bootstrap/bootstrap.py +++ b/toxygen/bootstrap/bootstrap.py @@ -13,6 +13,7 @@ except ImportError: from user_data.settings import get_user_config_path from wrapper_tests.support_testing import _get_nodes_path from wrapper_tests.support_http import download_url +import wrapper_tests.support_testing as ts global LOG import logging diff --git a/toxygen/contacts/group_chat.py b/toxygen/contacts/group_chat.py index 15aa0ec..74ac0e4 100644 --- a/toxygen/contacts/group_chat.py +++ b/toxygen/contacts/group_chat.py @@ -110,7 +110,6 @@ class GroupChat(contact.Contact, ToxSave): def get_peer_by_id(self, peer_id): peers = list(filter(lambda p: p.id == peer_id, self._peers)) if peers: - #? broken return peers[0] else: LOG_WARN(f"get_peer_by_id empty peers for {peer_id}") diff --git a/toxygen/middleware/threads.py b/toxygen/middleware/threads.py index 229563d..75377dc 100644 --- a/toxygen/middleware/threads.py +++ b/toxygen/middleware/threads.py @@ -95,7 +95,7 @@ class InitThread(BaseThread): try: if self._is_first_start and ts.bAreWeConnected() and \ self._settings['download_nodes_list']: - LOG_INFO('downloading list of nodes') + LOG_INFO(f"downloading list of nodes {self._settings['download_nodes_list']}") download_nodes_list(self._settings, oArgs=self._app._args) if ts.bAreWeConnected(): diff --git a/toxygen/middleware/tox_factory.py b/toxygen/middleware/tox_factory.py index 41d0044..feba040 100644 --- a/toxygen/middleware/tox_factory.py +++ b/toxygen/middleware/tox_factory.py @@ -101,8 +101,9 @@ def tox_factory(data=None, settings=None, args=None, app=None): LOG.debug("wrapper.tox.Tox settings: " +repr(settings)) - if 'trace_enabled' in settings and settings['trace_enabled'] and \ - tox_options._options_pointer: + if 'trace_enabled' in settings and settings['trace_enabled']: + LOG_INFO("settings['trace_enabled' disabled" ) + elif tox_options._options_pointer: c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p) tox_options.self_logger_cb = c_callback(tox_log_cb) wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback( diff --git a/toxygen/ui/main_screen.py b/toxygen/ui/main_screen.py index b7b0c52..d716d15 100644 --- a/toxygen/ui/main_screen.py +++ b/toxygen/ui/main_screen.py @@ -362,7 +362,7 @@ class MainWindow(QtWidgets.QMainWindow): self.actionLog_console.setText(util_ui.tr("Console Log")) self.actionPython_console.setText(util_ui.tr("Python Console")) self.actionTest_tox.setText(util_ui.tr("Bootstrap")) - self.actionTest_nmap.setText(util_ui.tr("Test Nmap")) + self.actionTest_nmap.setText(util_ui.tr("Test Nodes")) self.actionTest_main.setText(util_ui.tr("Test Program")) self.actionQuit_program.setText(util_ui.tr("Quit program")) self.actionSettings.setText(util_ui.tr("Settings")) diff --git a/toxygen/ui/peer_screen.py b/toxygen/ui/peer_screen.py index bd390d1..1d23f7e 100644 --- a/toxygen/ui/peer_screen.py +++ b/toxygen/ui/peer_screen.py @@ -29,9 +29,11 @@ class PeerScreen(CenteredWidget): self.statusCircle = StatusCircle(self) self.statusCircle.setGeometry(50, 15, 30, 30) - self.statusCircle.update(self._peer.status) - self.peerNameLabel.setText(self._peer.name) - self.ignorePeerCheckBox.setChecked(self._peer.is_muted) + if self._peer: + self.statusCircle.update(self._peer.status) + self.peerNameLabel.setText(self._peer.name) + self.ignorePeerCheckBox.setChecked(self._peer.is_muted) + self.ignorePeerCheckBox.clicked.connect(self._toggle_ignore) self.sendPrivateMessagePushButton.clicked.connect(self._send_private_message) self.copyPublicKeyPushButton.clicked.connect(self._copy_public_key) diff --git a/toxygen/user_data/settings.py b/toxygen/user_data/settings.py index 7fdcca5..caf454c 100644 --- a/toxygen/user_data/settings.py +++ b/toxygen/user_data/settings.py @@ -162,7 +162,7 @@ class Settings(dict): info = Settings.get_default_settings(app._oArgs) if not os.path.exists(path): - merge_oArgs_into_settings(app._oArgs, info) + merge_args_into_settings(app._oArgs, info) else: aC = self._changed(app._oArgs, info) if aC: @@ -175,7 +175,7 @@ class Settings(dict): text += repr(aC) reply = util_ui.question(text, title) if reply: - merge_oArgs_into_settings(app._oArgs, info) + merge_args_into_settings(app._oArgs, info) info['audio'] = getattr(app._oArgs, 'audio') info['video'] = getattr(app._oArgs, 'video') super().__init__(info)