From f7e260a355e5bca107e5ea65192e018ba2b2562e Mon Sep 17 00:00:00 2001 From: "emdee@spm.plastiras.org" Date: Mon, 12 Feb 2024 13:14:59 +0000 Subject: [PATCH] AudioQThread --- toxygen/.#.pylint.out | 1 + toxygen/__main__.py | 11 +++++------ toxygen/av/calls.py | 7 +++---- toxygen/av/calls_manager.py | 1 + toxygen/bootstrap/bootstrap.py | 8 ++++---- toxygen/contacts/contact_provider.py | 6 +++--- toxygen/contacts/friend.py | 6 +++--- toxygen/file_transfers/file_transfers.py | 6 +++--- toxygen/file_transfers/file_transfers_handler.py | 6 +++--- toxygen/user_data/settings.py | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) create mode 120000 toxygen/.#.pylint.out diff --git a/toxygen/.#.pylint.out b/toxygen/.#.pylint.out new file mode 120000 index 0000000..ba3c68c --- /dev/null +++ b/toxygen/.#.pylint.out @@ -0,0 +1 @@ +root@pentoo.5923:1706589296 \ No newline at end of file diff --git a/toxygen/__main__.py b/toxygen/__main__.py index b507230..73c4785 100644 --- a/toxygen/__main__.py +++ b/toxygen/__main__.py @@ -1,24 +1,22 @@ # -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*- import sys import os -import app import logging import signal import time +import warnings +import faulthandler from gevent import monkey; monkey.patch_all(); del monkey # noqa -import faulthandler faulthandler.enable() - -import warnings warnings.filterwarnings('ignore') import toxygen_wrapper.tests.support_testing as ts try: from trepan.interfaces import server as Mserver from trepan.api import debug -except: +except Exception as e: print('trepan3 TCP server NOT enabled.') else: import signal @@ -27,6 +25,7 @@ else: print('trepan3 TCP server enabled on port 6666.') except: pass +import app from user_data.settings import * from user_data.settings import Settings from user_data import settings @@ -40,7 +39,7 @@ __version__ = '1.0.0' # was 0.5.0+ path = os.path.dirname(os.path.realpath(__file__)) # curr dir sys.path.insert(0, os.path.join(path, 'styles')) sys.path.insert(0, os.path.join(path, 'plugins')) -sys.path.insert(0, os.path.join(path, 'third_party')) +# sys.path.insert(0, os.path.join(path, 'third_party')) sys.path.insert(0, path) sleep = time.sleep diff --git a/toxygen/av/calls.py b/toxygen/av/calls.py index 2ef613d..a1d0922 100644 --- a/toxygen/av/calls.py +++ b/toxygen/av/calls.py @@ -1,6 +1,7 @@ # -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*- import time import threading +import logging import itertools from toxygen_wrapper.toxav_enums import * @@ -14,14 +15,12 @@ from av.call import Call import common.tox_save from utils import ui as util_ui -import toxygen_wrapper.tests.support_testing as ts from middleware.threads import invoke_in_main_thread -from middleware.threads import BaseThread, BaseQThread +# from middleware.threads import BaseThread sleep = time.sleep global LOG -import logging LOG = logging.getLogger('app.'+__name__) TIMER_TIMEOUT = 30.0 @@ -463,7 +462,7 @@ class AV(common.tox_save.ToxAvSave): count, self._audio_channels, self._audio_rate_tox) -ts) + except Exception as e: LOG.error(f"Error send_audio_data audio_send_frame: {e}") LOG.debug(f"send_audio_data self._audio_rate_tox={self._audio_rate_tox} self._audio_channels={self._audio_channels}") diff --git a/toxygen/av/calls_manager.py b/toxygen/av/calls_manager.py index aedcd19..ac645c8 100644 --- a/toxygen/av/calls_manager.py +++ b/toxygen/av/calls_manager.py @@ -12,6 +12,7 @@ from messenger.messages import * from ui import av_widgets import common.event as event import utils.ui as util_ui +from toxygen_wrapper.tests import support_testing as ts global LOG LOG = logging.getLogger('app.'+__name__) diff --git a/toxygen/bootstrap/bootstrap.py b/toxygen/bootstrap/bootstrap.py index 506b248..542900a 100644 --- a/toxygen/bootstrap/bootstrap.py +++ b/toxygen/bootstrap/bootstrap.py @@ -1,8 +1,7 @@ # -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*- import random -import urllib.request -from utils.util import * -from qtpy import QtNetwork +import logging + from qtpy import QtCore try: import certifi @@ -11,12 +10,13 @@ except ImportError: certifi = None from user_data.settings import get_user_config_path +from utils.util import * + from toxygen_wrapper.tests.support_testing import _get_nodes_path from toxygen_wrapper.tests.support_http import download_url import toxygen_wrapper.tests.support_testing as ts global LOG -import logging LOG = logging.getLogger('app.'+'bootstrap') def download_nodes_list(settings, oArgs): diff --git a/toxygen/contacts/contact_provider.py b/toxygen/contacts/contact_provider.py index ecd42d6..1d7faf0 100644 --- a/toxygen/contacts/contact_provider.py +++ b/toxygen/contacts/contact_provider.py @@ -41,14 +41,14 @@ class ContactProvider(tox_save.ToxSave): LOG_DEBUG(f"CP.get_friend_by_public_key ADDED {friend} ") return friend - def get_all_friends(self): + def get_all_friends(self) -> list: if self._app and self._app.bAppExiting: - return + return [] try: friend_numbers = self._tox.self_get_friend_list() except Exception as e: LOG_WARN(f"CP.get_all_friends EXCEPTION {e} ") - return None + return [] friends = map(lambda n: self.get_friend_by_number(n), friend_numbers) return list(friends) diff --git a/toxygen/contacts/friend.py b/toxygen/contacts/friend.py index 549b480..084672a 100644 --- a/toxygen/contacts/friend.py +++ b/toxygen/contacts/friend.py @@ -1,9 +1,9 @@ +import os + from contacts import contact, common from messenger.messages import * -import os from contacts.contact_menu import * - class Friend(contact.Contact): """ Friend in list of friends. @@ -27,7 +27,7 @@ class Friend(contact.Contact): self._corr.insert(i, inline) return i - len(self._corr) except: - pass + return -1 def get_unsent_files(self): messages = filter(lambda m: type(m) is UnsentFileMessage, self._corr) diff --git a/toxygen/file_transfers/file_transfers.py b/toxygen/file_transfers/file_transfers.py index 9b31c5c..a4a1e09 100644 --- a/toxygen/file_transfers/file_transfers.py +++ b/toxygen/file_transfers/file_transfers.py @@ -328,11 +328,11 @@ class ReceiveAvatar(ReceiveTransfer): self._file.close() remove(full_path) elif exists(path): - hash = self.get_file_id() + ihash = self.get_file_id() with open(path, 'rb') as fl: data = fl.read() - existing_hash = Tox.hash(data) - if hash == existing_hash: + existing_ihash = Tox.hash(data) + if ihash == existing_hash: self.send_control(TOX_FILE_CONTROL['CANCEL']) self._file.close() remove(full_path) diff --git a/toxygen/file_transfers/file_transfers_handler.py b/toxygen/file_transfers/file_transfers_handler.py index 557746e..69d042c 100644 --- a/toxygen/file_transfers/file_transfers_handler.py +++ b/toxygen/file_transfers/file_transfers_handler.py @@ -50,7 +50,7 @@ class FileTransfersHandler(ToxSave): friend = self._get_friend_by_number(friend_number) if friend is None: LOG.info(f'incoming_file_handler Friend NULL friend_number={friend_number}') - return None + return auto = self._settings['allow_auto_accept'] and friend.tox_id in self._settings['auto_accept_from_friends'] inline = False # ?is_inline(file_name) and self._settings['allow_inline'] file_id = self._tox.file_get_file_id(friend_number, file_number) @@ -234,7 +234,7 @@ class FileTransfersHandler(ToxSave): def send_files(self, friend_number): try: friend = self._get_friend_by_number(friend_number) - if friend is None: return None + if friend is None: return friend.remove_invalid_unsent_files() files = friend.get_unsent_files() for fl in files: @@ -317,7 +317,7 @@ class FileTransfersHandler(ToxSave): :param size: size of avatar or 0 (default avatar) """ friend = self._get_friend_by_number(friend_number) - if friend is None: return None + if friend is None: return ra = ReceiveAvatar(friend.get_contact_avatar_path(), self._tox, friend_number, size, file_number) if ra.state != FILE_TRANSFER_STATE['CANCELLED']: self._file_transfers[(friend_number, file_number)] = ra diff --git a/toxygen/user_data/settings.py b/toxygen/user_data/settings.py index 2a89644..7c9a2fc 100644 --- a/toxygen/user_data/settings.py +++ b/toxygen/user_data/settings.py @@ -237,7 +237,7 @@ class Settings(dict): Mark current profile as active """ if not profile_path: - profile_path = get_auto_profile() + profile_path = self.get_auto_profile() path = profile_path + '.lock' try: