diff --git a/openfreebuds/driver/generic/base.py b/openfreebuds/driver/generic/base.py index 8c15a20..9a2efd3 100644 --- a/openfreebuds/driver/generic/base.py +++ b/openfreebuds/driver/generic/base.py @@ -1,4 +1,3 @@ -import json from typing import Optional from openfreebuds.constants import OfbEventKind diff --git a/openfreebuds/driver/huawei/driver/generic.py b/openfreebuds/driver/huawei/driver/generic.py index 0d659f9..7dc56fc 100644 --- a/openfreebuds/driver/huawei/driver/generic.py +++ b/openfreebuds/driver/huawei/driver/generic.py @@ -1,5 +1,4 @@ import asyncio -from contextlib import suppress from openfreebuds.driver.generic import OfbDriverHandlerGeneric, OfbDriverSppGeneric from openfreebuds.driver.huawei.package import HuaweiSppPackage diff --git a/openfreebuds/driver/huawei/package.py b/openfreebuds/driver/huawei/package.py index 1ce12a7..91d8e32 100644 --- a/openfreebuds/driver/huawei/package.py +++ b/openfreebuds/driver/huawei/package.py @@ -60,7 +60,7 @@ def to_table_string(self): out += "\n" return out - def find_param(self, *args, **kwargs) -> bytes: + def find_param(self, *args) -> bytes: """ Get parameter value by one of provided types """ diff --git a/openfreebuds/driver/huawei/utils.py b/openfreebuds/driver/huawei/utils.py index e957bdb..5076fea 100644 --- a/openfreebuds/driver/huawei/utils.py +++ b/openfreebuds/driver/huawei/utils.py @@ -1,6 +1,3 @@ -from array import array - - def build_table_row(ln, val, description_table=None): if description_table is not None and val in description_table: val = f"{val} ({description_table[val]})" diff --git a/openfreebuds/manager/main.py b/openfreebuds/manager/main.py index 6e8a746..249db74 100644 --- a/openfreebuds/manager/main.py +++ b/openfreebuds/manager/main.py @@ -5,7 +5,6 @@ from aiohttp.web_routedef import RouteTableDef -import openfreebuds_backend from openfreebuds import webserver from openfreebuds.constants import OfbEventKind from openfreebuds.driver import DEVICE_TO_DRIVER_MAP diff --git a/openfreebuds/utils/event_bus.py b/openfreebuds/utils/event_bus.py index 753d0e7..27a8944 100644 --- a/openfreebuds/utils/event_bus.py +++ b/openfreebuds/utils/event_bus.py @@ -27,6 +27,7 @@ def include_subscription(self, callback_id: str, subscription): self._child_subs[callback_id].cancel() async def _handler(): + # noinspection PyProtectedMember queue = subscription._new_queue(callback_id, None) while True: await self.send_message(*(await queue.get())) diff --git a/openfreebuds_backend/errors.py b/openfreebuds_backend/errors.py deleted file mode 100644 index 9f4747d..0000000 --- a/openfreebuds_backend/errors.py +++ /dev/null @@ -1,2 +0,0 @@ -class BluetoothNotAvailableError(ValueError): - pass diff --git a/openfreebuds_backend/windows/bt_win32.py b/openfreebuds_backend/windows/bt_win32.py index c6644d2..74de726 100644 --- a/openfreebuds_backend/windows/bt_win32.py +++ b/openfreebuds_backend/windows/bt_win32.py @@ -10,7 +10,6 @@ # noinspection PyUnresolvedReferences,PyPackageRequirements from winsdk.windows.networking import HostName -from openfreebuds_backend.errors import BluetoothNotAvailableError from openfreebuds_backend.exception import OfbBackendDependencyMissingError extra_tools_dir = 'C:\\Program Files (x86)\\Bluetooth Command Line Tools\\bin' @@ -76,7 +75,7 @@ async def bt_list_devices(): selector = BluetoothDevice.get_device_selector_from_pairing_state(True) devices = await DeviceInformation.find_all_async(selector, [], DeviceInformationKind.DEVICE) except OSError: - raise BluetoothNotAvailableError("Got OSError, looks like bluetooth isn't installed") + return [] for a in devices: try: diff --git a/openfreebuds_backend/windows/misc_win32.py b/openfreebuds_backend/windows/misc_win32.py index c0b0fd6..4c2b78f 100644 --- a/openfreebuds_backend/windows/misc_win32.py +++ b/openfreebuds_backend/windows/misc_win32.py @@ -1,4 +1,3 @@ -import os import pathlib import subprocess import sys diff --git a/openfreebuds_backend/windows/ui_win32.py b/openfreebuds_backend/windows/ui_win32.py index 3395cb7..f6ee34d 100644 --- a/openfreebuds_backend/windows/ui_win32.py +++ b/openfreebuds_backend/windows/ui_win32.py @@ -1,4 +1,3 @@ -import logging import winreg diff --git a/openfreebuds_cmd/__main__.py b/openfreebuds_cmd/__main__.py index a1f9a6c..b2ca018 100644 --- a/openfreebuds_cmd/__main__.py +++ b/openfreebuds_cmd/__main__.py @@ -1,3 +1,3 @@ from .launcher import main -main() \ No newline at end of file +main() diff --git a/openfreebuds_qt/app/module/about.py b/openfreebuds_qt/app/module/about.py index efcf062..ba7b30f 100644 --- a/openfreebuds_qt/app/module/about.py +++ b/openfreebuds_qt/app/module/about.py @@ -5,7 +5,7 @@ from openfreebuds import DEVICE_TO_DRIVER_MAP from openfreebuds_qt.app.module.common import OfbQtCommonModule -from openfreebuds_qt.constants import LINK_WEBSITE, LINK_GITHUB, ASSETS_PATH +from openfreebuds_qt.constants import LINK_WEBSITE, LINK_GITHUB from openfreebuds_qt.designer.about_module import Ui_OfbQtAboutModule from openfreebuds_qt.version_info import VERSION, LIBRARIES diff --git a/openfreebuds_qt/app/module/dual_connect.py b/openfreebuds_qt/app/module/dual_connect.py index 7e56d18..ff420e7 100644 --- a/openfreebuds_qt/app/module/dual_connect.py +++ b/openfreebuds_qt/app/module/dual_connect.py @@ -68,16 +68,12 @@ async def on_connect_toggle(self): async with qt_error_handler("OfbQtDualConnectModule_ToggleConnect", self.ctx): addr, data = self._all_data[self._current_index] - try: - self.button_toggle_connect.setEnabled(False) - await self.ofb.set_property( - "dual_connect", - f"{addr}:connected", - json.dumps(not data["connected"]) - ) - except Exception: - log.exception(f"Trying to switch connection state of {addr}") - self.button_toggle_connect.setEnabled(True) + self.button_toggle_connect.setEnabled(False) + await self.ofb.set_property( + "dual_connect", + f"{addr}:connected", + json.dumps(not data["connected"]) + ) def _update_current_device_view(self, addr: str, data: dict): self.current_device_name.setText(data['name']) diff --git a/openfreebuds_qt/app/module/linux_related.py b/openfreebuds_qt/app/module/linux_related.py index 0325073..ea38605 100644 --- a/openfreebuds_qt/app/module/linux_related.py +++ b/openfreebuds_qt/app/module/linux_related.py @@ -1,6 +1,5 @@ import os import webbrowser -from contextlib import suppress from PyQt6.QtCore import pyqtSlot from PyQt6.QtWidgets import QMessageBox diff --git a/openfreebuds_qt/app/module/sound_quality.py b/openfreebuds_qt/app/module/sound_quality.py index c506977..7040270 100644 --- a/openfreebuds_qt/app/module/sound_quality.py +++ b/openfreebuds_qt/app/module/sound_quality.py @@ -2,7 +2,7 @@ import json from PyQt6.QtCore import Qt -from PyQt6.QtWidgets import QSlider, QMenu, QInputDialog, QMessageBox, QFileDialog, QApplication +from PyQt6.QtWidgets import QSlider, QMenu, QInputDialog, QMessageBox, QFileDialog from qasync import asyncSlot from openfreebuds.exceptions import OfbTooManyItemsError diff --git a/openfreebuds_qt/assets/icon.ico b/openfreebuds_qt/assets/icon.ico deleted file mode 100644 index e80999b..0000000 Binary files a/openfreebuds_qt/assets/icon.ico and /dev/null differ diff --git a/openfreebuds_qt/config/config_lock.py b/openfreebuds_qt/config/config_lock.py index 90ee785..b0ef35d 100644 --- a/openfreebuds_qt/config/config_lock.py +++ b/openfreebuds_qt/config/config_lock.py @@ -1,11 +1,11 @@ import os import sys from pathlib import Path + from psutil import Process, AccessDenied, NoSuchProcess +from openfreebuds.constants import STORAGE_PATH from openfreebuds.utils.logger import create_logger -from openfreebuds_qt.constants import STORAGE_PATH - log = create_logger("ConfigLock") diff --git a/openfreebuds_qt/config/main.py b/openfreebuds_qt/config/main.py index 0213ca3..352122b 100644 --- a/openfreebuds_qt/config/main.py +++ b/openfreebuds_qt/config/main.py @@ -5,8 +5,8 @@ from qasync import QApplication +from openfreebuds.constants import STORAGE_PATH from openfreebuds_backend import is_dark_taskbar -from openfreebuds_qt.constants import STORAGE_PATH CONFIG_PATH = STORAGE_PATH / "openfreebuds_qt.json" diff --git a/openfreebuds_qt/constants.py b/openfreebuds_qt/constants.py index 5621d87..e53ae51 100644 --- a/openfreebuds_qt/constants.py +++ b/openfreebuds_qt/constants.py @@ -1,4 +1,4 @@ -from openfreebuds import APP_ROOT, STORAGE_PATH +from openfreebuds import APP_ROOT ASSETS_PATH = APP_ROOT / "openfreebuds_qt" / "assets" I18N_PATH = APP_ROOT / "openfreebuds_qt" / "assets" / "i18n" diff --git a/openfreebuds_qt/main.py b/openfreebuds_qt/main.py index cf7237f..c823f96 100644 --- a/openfreebuds_qt/main.py +++ b/openfreebuds_qt/main.py @@ -10,10 +10,11 @@ from qasync import QEventLoop from openfreebuds import IOpenFreebuds, create as create_ofb, OfbEventKind +from openfreebuds.constants import STORAGE_PATH from openfreebuds.utils.logger import setup_logging, screen_handler, create_logger from openfreebuds_qt.app.main import OfbQtMainWindow from openfreebuds_qt.config import OfbQtConfigParser, ConfigLock -from openfreebuds_qt.constants import IGNORED_LOG_TAGS, I18N_PATH, STORAGE_PATH +from openfreebuds_qt.constants import IGNORED_LOG_TAGS, I18N_PATH from openfreebuds_qt.generic import IOfbQtApplication from openfreebuds_qt.tray.main import OfbTrayIcon from openfreebuds_qt.utils import OfbQtDeviceAutoSelect, OfbQtHotkeyService, list_available_locales @@ -123,8 +124,6 @@ async def boot(self): self.qt_app.exit(e.args[0]) ConfigLock.release() return - except Exception: - log.exception("App boot failed") async def exit(self, ret_code: int = 0): await self.tray.close() diff --git a/openfreebuds_qt/tray/menu.py b/openfreebuds_qt/tray/menu.py index 4be1fb8..b373984 100644 --- a/openfreebuds_qt/tray/menu.py +++ b/openfreebuds_qt/tray/menu.py @@ -1,5 +1,4 @@ from datetime import datetime -from typing import Optional from PyQt6.QtGui import QAction from qasync import asyncSlot @@ -7,13 +6,13 @@ from openfreebuds import IOpenFreebuds, OfbEventKind from openfreebuds_backend.exception import OfbBackendDependencyMissingError from openfreebuds_qt.config import OfbQtConfigParser +from openfreebuds_qt.generic import IOfbTrayIcon, IOfbQtApplication from openfreebuds_qt.tray.dialogs import OfbQtDependencyMissingDialog +from openfreebuds_qt.tray.menu_anc_level import OfbDeviceAncLevelTrayMenu from openfreebuds_qt.tray.menu_dual_connect import OfbDeviceDualConnectTrayMenu from openfreebuds_qt.tray.menu_equalizer import OfbDeviceEqualizerTrayMenu -from openfreebuds_qt.utils.core_event import OfbCoreEvent -from openfreebuds_qt.generic import IOfbTrayIcon, IOfbQtApplication from openfreebuds_qt.tray.menu_generic import OfbQtTrayMenuCommon -from openfreebuds_qt.tray.menu_anc_level import OfbDeviceAncLevelTrayMenu +from openfreebuds_qt.utils.core_event import OfbCoreEvent from openfreebuds_qt.utils.report_tool import OfbQtReportTool @@ -84,10 +83,8 @@ def __init__(self, tray: IOfbTrayIcon, context: IOfbQtApplication, ofb: IOpenFre # Footer self.new_section() - self.add_item(self.tr("Bugreport..."), - callback=self.do_bugreport) - self.add_item(self.tr("Leave application"), - callback=self.do_exit) + self.add_item(self.tr("Bugreport..."), callback=self.do_bugreport) + self.add_item(self.tr("Leave application"), callback=self.do_exit) async def on_core_event(self, event: OfbCoreEvent, state: int): if event.kind_in([OfbEventKind.STATE_CHANGED, OfbEventKind.QT_SETTINGS_CHANGED]): diff --git a/openfreebuds_qt/tray/menu_dual_connect.py b/openfreebuds_qt/tray/menu_dual_connect.py index cdeed99..718e900 100644 --- a/openfreebuds_qt/tray/menu_dual_connect.py +++ b/openfreebuds_qt/tray/menu_dual_connect.py @@ -25,7 +25,7 @@ async def update_ui(self): def _add_item(self, addr: str, display_name: str, active: bool = False): @asyncSlot() async def toggle(_): - await self.ofb.set_property("dual_connect", f"{addr}:connected", not active) + await self.ofb.set_property("dual_connect", f"{addr}:connected", json.dumps(not active)) await self.update_ui() self.add_item(text=display_name, diff --git a/openfreebuds_qt/utils/hotkeys/recorder.py b/openfreebuds_qt/utils/hotkeys/recorder.py index e459f8f..e005675 100644 --- a/openfreebuds_qt/utils/hotkeys/recorder.py +++ b/openfreebuds_qt/utils/hotkeys/recorder.py @@ -68,7 +68,7 @@ def on_release(self, pressed_key): from pynput import keyboard if isinstance(pressed_key, keyboard.Key): val = str(pressed_key).replace("Key.", "") - if val == "esc" and len(self._specials) == 1 : + if val == "esc" and len(self._specials) == 1: self.cancel() return if val in self._specials: diff --git a/openfreebuds_qt/utils/mpris/service.py b/openfreebuds_qt/utils/mpris/service.py index e52442d..2234b12 100644 --- a/openfreebuds_qt/utils/mpris/service.py +++ b/openfreebuds_qt/utils/mpris/service.py @@ -10,7 +10,7 @@ try: from openfreebuds_backend.linux.dbus.mpris import MPRISPProxy except ImportError: - pass + MPRISPProxy = None log = create_logger("OfbQtMPRISHelperService") diff --git a/openfreebuds_qt/utils/report_tool.py b/openfreebuds_qt/utils/report_tool.py index a5af8e8..2c7b14e 100644 --- a/openfreebuds_qt/utils/report_tool.py +++ b/openfreebuds_qt/utils/report_tool.py @@ -6,10 +6,10 @@ from PyQt6.QtCore import QT_VERSION_STR, PYQT_VERSION_STR import openfreebuds_backend +from openfreebuds.constants import STORAGE_PATH from openfreebuds.utils.logger import get_full_log from openfreebuds_qt.config import OfbQtConfigParser from openfreebuds_qt.config.config_lock import ConfigLock -from openfreebuds_qt.constants import STORAGE_PATH from openfreebuds_qt.generic import IOfbQtApplication from openfreebuds_qt.version_info import VERSION diff --git a/openfreebuds_qt/utils/updater/service.py b/openfreebuds_qt/utils/updater/service.py index d999016..9c15c91 100644 --- a/openfreebuds_qt/utils/updater/service.py +++ b/openfreebuds_qt/utils/updater/service.py @@ -1,11 +1,10 @@ import sys -from typing import Optional from PyQt6.QtWidgets import QWidget +from openfreebuds.constants import STORAGE_PATH from openfreebuds.utils.logger import create_logger from openfreebuds_qt.config import OfbQtConfigParser -from openfreebuds_qt.constants import STORAGE_PATH from openfreebuds_qt.version_info import VERSION try: diff --git a/scripts/bump_version.py b/scripts/bump_version.py index 699f2b5..9946416 100644 --- a/scripts/bump_version.py +++ b/scripts/bump_version.py @@ -13,6 +13,7 @@ URL_FLATPAK_PIP_GENERATOR = ("https://github.com/flatpak/flatpak-builder-tools/raw/refs/heads/master" "/pip/flatpak-pip-generator") +BASE_CHANGELOG_URL = "https://github.com/melianmiko/OpenFreebuds/blob/main/CHANGELOG.md" PROJECT_ROOT = Path(__file__).parents[1] FLATPAK_PIP_GENERATOR_PATH = PROJECT_ROOT / "scripts" / "tools" / "flatpak-pip-generator" @@ -120,7 +121,7 @@ def bump_metainfo(line: str): new_data = [ line, f' ', - f' https://github.com/melianmiko/OpenFreebuds/blob/main/CHANGELOG.md#v{NEW_VERSION}', + f' {BASE_CHANGELOG_URL}#v{NEW_VERSION}', f' ', f'