Compare commits

..

No commits in common. "58a26e89a8c48fa6cf036665beef7dcc5d5182e2" and "6b79c091e8ea7e420e20d4cdc94dbebf1f04d8a7" have entirely different histories.

4 changed files with 23 additions and 26 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "voicemeeter-api" name = "voicemeeter-api"
version = "2.4.1" version = "2.3.7"
description = "A Python wrapper for the Voiceemeter API" description = "A Python wrapper for the Voiceemeter API"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -1,22 +1,19 @@
class VMError(Exception): class InstallError(Exception):
"""Base VM Exception class. Raised when general errors occur.""" """Exception raised when installation errors occur"""
def __init__(self, msg):
self.message = msg class CAPIError(Exception):
"""Exception raised when the C-API returns error values"""
def __init__(self, fn_name, code, msg=None):
self.fn_name = fn_name
self.code = code
self.message = msg if msg else f"{fn_name} returned {code}"
super().__init__(self.message) super().__init__(self.message)
def __str__(self): def __str__(self):
return f"{type(self).__name__}: {self.message}" return f"{type(self).__name__}: {self.message}"
class InstallError(VMError): class VMError(Exception):
"""Exception raised when installation errors occur""" """Exception raised when general errors occur"""
class CAPIError(VMError):
"""Exception raised when the C-API returns an error code"""
def __init__(self, fn_name, code, msg=None):
self.fn_name = fn_name
self.code = code
super(CAPIError, self).__init__(msg if msg else f"{fn_name} returned {code}")

View File

@ -2,7 +2,7 @@ import logging
from abc import abstractmethod from abc import abstractmethod
from enum import IntEnum from enum import IntEnum
from functools import cached_property from functools import cached_property
from typing import Iterable from typing import Iterable, NoReturn
from . import misc from . import misc
from .bus import request_bus_obj as bus from .bus import request_bus_obj as bus
@ -51,7 +51,7 @@ class FactoryBuilder:
) )
self.logger = logger.getChild(self.__class__.__name__) self.logger = logger.getChild(self.__class__.__name__)
def _pinfo(self, name: str) -> None: def _pinfo(self, name: str) -> NoReturn:
"""prints progress status for each step""" """prints progress status for each step"""
name = name.split("_")[1] name = name.split("_")[1]
self.logger.debug(self._info[int(getattr(self.BuilderProgress, name))]) self.logger.debug(self._info[int(getattr(self.BuilderProgress, name))])

View File

@ -3,7 +3,7 @@ import logging
import time import time
from abc import abstractmethod from abc import abstractmethod
from queue import Queue from queue import Queue
from typing import Iterable, Optional, Union from typing import Iterable, NoReturn, Optional, Union
from .cbindings import CBindings from .cbindings import CBindings
from .error import CAPIError, VMError from .error import CAPIError, VMError
@ -62,7 +62,7 @@ class Remote(CBindings):
self.producer = Producer(self, queue) self.producer = Producer(self, queue)
self.producer.start() self.producer.start()
def login(self) -> None: def login(self) -> NoReturn:
"""Login to the API, initialize dirty parameters""" """Login to the API, initialize dirty parameters"""
self.gui.launched = self.call(self.bind_login, ok=(0, 1)) == 0 self.gui.launched = self.call(self.bind_login, ok=(0, 1)) == 0
if not self.gui.launched: if not self.gui.launched:
@ -75,7 +75,7 @@ class Remote(CBindings):
) )
self.clear_dirty() self.clear_dirty()
def run_voicemeeter(self, kind_id: str) -> None: def run_voicemeeter(self, kind_id: str) -> NoReturn:
if kind_id not in (kind.name.lower() for kind in KindId): if kind_id not in (kind.name.lower() for kind in KindId):
raise VMError(f"Unexpected Voicemeeter type: '{kind_id}'") raise VMError(f"Unexpected Voicemeeter type: '{kind_id}'")
if kind_id == "potato" and bits == 8: if kind_id == "potato" and bits == 8:
@ -133,7 +133,7 @@ class Remote(CBindings):
and self.cache.get("bus_level") == self._bus_buf and self.cache.get("bus_level") == self._bus_buf
) )
def clear_dirty(self) -> None: def clear_dirty(self) -> NoReturn:
try: try:
while self.pdirty or self.mdirty: while self.pdirty or self.mdirty:
pass pass
@ -155,7 +155,7 @@ class Remote(CBindings):
self.call(self.bind_get_parameter_float, param.encode(), ct.byref(buf)) self.call(self.bind_get_parameter_float, param.encode(), ct.byref(buf))
return buf.value return buf.value
def set(self, param: str, val: Union[str, float]) -> None: def set(self, param: str, val: Union[str, float]) -> NoReturn:
"""Sets a string or float parameter. Caches value""" """Sets a string or float parameter. Caches value"""
if isinstance(val, str): if isinstance(val, str):
if len(val) >= 512: if len(val) >= 512:
@ -191,7 +191,7 @@ class Remote(CBindings):
) from e ) from e
return int(c_state.value) return int(c_state.value)
def set_buttonstatus(self, id_: int, val: int, mode: int) -> None: def set_buttonstatus(self, id_: int, val: int, mode: int) -> NoReturn:
"""Sets a macrobutton parameter. Caches value""" """Sets a macrobutton parameter. Caches value"""
c_state = ct.c_float(float(val)) c_state = ct.c_float(float(val))
try: try:
@ -334,13 +334,13 @@ class Remote(CBindings):
self.logger.debug("events thread shutdown started") self.logger.debug("events thread shutdown started")
self.running = False self.running = False
def logout(self) -> None: def logout(self) -> NoReturn:
"""Logout of the API""" """Logout of the API"""
time.sleep(0.1) time.sleep(0.1)
self.call(self.bind_logout) self.call(self.bind_logout)
self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}") self.logger.info(f"{type(self).__name__}: Successfully logged out of {self}")
def __exit__(self, exc_type, exc_value, exc_traceback) -> None: def __exit__(self, exc_type, exc_value, exc_traceback) -> NoReturn:
"""teardown procedures""" """teardown procedures"""
self.end_thread() self.end_thread()
self.logout() self.logout()