mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2025-01-18 18:40:47 +00:00
fixes bug with apply() if called from higher class
This commit is contained in:
parent
2c8e4cc87c
commit
1ad0347478
@ -11,7 +11,7 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
|
|
||||||
- [x]
|
- [x]
|
||||||
|
|
||||||
## [2.1.1] - 2023-07-05
|
## [2.1.2] - 2023-07-05
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
@ -21,6 +21,12 @@ This is useful if you are only interested in sending commands out to voicemeeter
|
|||||||
|
|
||||||
By default outbound is False.
|
By default outbound is False.
|
||||||
|
|
||||||
|
- sendtext logging added in base class.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Bug in apply() if invoked from a higher class (not base class)
|
||||||
|
|
||||||
## [2.0.0] - 2023-06-25
|
## [2.0.0] - 2023-06-25
|
||||||
|
|
||||||
This update introduces some breaking changes:
|
This update introduces some breaking changes:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "vban-cmd"
|
name = "vban-cmd"
|
||||||
version = "2.1.1"
|
version = "2.1.2"
|
||||||
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
description = "Python interface for the VBAN RT Packet Service (Sendtext)"
|
||||||
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
authors = ["onyx-and-iris <code@onyxandiris.online>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -102,7 +102,7 @@ class IRemote(metaclass=ABCMeta):
|
|||||||
def setter(self, param, val):
|
def setter(self, param, val):
|
||||||
"""Sends a string request RT packet."""
|
"""Sends a string request RT packet."""
|
||||||
self.logger.debug(f"setter: {self._cmd(param)}={val}")
|
self.logger.debug(f"setter: {self._cmd(param)}={val}")
|
||||||
self._remote._set_rt(self.identifier, param, val)
|
self._remote._set_rt(self._cmd(param), val)
|
||||||
|
|
||||||
def _cmd(self, param):
|
def _cmd(self, param):
|
||||||
cmd = (self.identifier,)
|
cmd = (self.identifier,)
|
||||||
@ -141,10 +141,10 @@ class IRemote(metaclass=ABCMeta):
|
|||||||
else:
|
else:
|
||||||
target = getattr(self, attr)
|
target = getattr(self, attr)
|
||||||
target.apply(val)
|
target.apply(val)
|
||||||
|
|
||||||
|
self._remote.sendtext(self._remote._script)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def then_wait(self):
|
def then_wait(self):
|
||||||
self.logger.debug(self._remote._script)
|
|
||||||
self._remote.sendtext(self._remote._script)
|
|
||||||
self._remote._script = str()
|
self._remote._script = str()
|
||||||
time.sleep(self._remote.DELAY)
|
time.sleep(self._remote.DELAY)
|
||||||
|
@ -48,6 +48,7 @@ class VbanCmd(metaclass=ABCMeta):
|
|||||||
self.cache = {}
|
self.cache = {}
|
||||||
self._pdirty = False
|
self._pdirty = False
|
||||||
self._ldirty = False
|
self._ldirty = False
|
||||||
|
self._script = str()
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -101,34 +102,28 @@ class VbanCmd(metaclass=ABCMeta):
|
|||||||
|
|
||||||
self.logger.info(f"{type(self).__name__}: Successfully logged into {self}")
|
self.logger.info(f"{type(self).__name__}: Successfully logged into {self}")
|
||||||
|
|
||||||
def _set_rt(
|
def _set_rt(self, cmd: str, val: Union[str, float]):
|
||||||
self,
|
|
||||||
id_: str,
|
|
||||||
param: Optional[str] = None,
|
|
||||||
val: Optional[Union[int, float]] = None,
|
|
||||||
):
|
|
||||||
"""Sends a string request command over a network."""
|
"""Sends a string request command over a network."""
|
||||||
cmd = f"{id_}={val};" if not param else f"{id_}.{param}={val};"
|
|
||||||
self.socks[Socket.request].sendto(
|
self.socks[Socket.request].sendto(
|
||||||
self.packet_request.header + cmd.encode(),
|
self.packet_request.header + f"{cmd}={val};".encode(),
|
||||||
(socket.gethostbyname(self.ip), self.port),
|
(socket.gethostbyname(self.ip), self.port),
|
||||||
)
|
)
|
||||||
self.packet_request.framecounter = (
|
self.packet_request.framecounter = (
|
||||||
int.from_bytes(self.packet_request.framecounter, "little") + 1
|
int.from_bytes(self.packet_request.framecounter, "little") + 1
|
||||||
).to_bytes(4, "little")
|
).to_bytes(4, "little")
|
||||||
if param:
|
self.cache[cmd] = val
|
||||||
self.cache[f"{id_}.{param}"] = val
|
|
||||||
|
|
||||||
@script
|
@script
|
||||||
def sendtext(self, cmd):
|
def sendtext(self, script):
|
||||||
"""Sends a multiple parameter string over a network."""
|
"""Sends a multiple parameter string over a network."""
|
||||||
self.socks[Socket.request].sendto(
|
self.socks[Socket.request].sendto(
|
||||||
self.packet_request.header + cmd.encode(),
|
self.packet_request.header + script.encode(),
|
||||||
(socket.gethostbyname(self.ip), self.port),
|
(socket.gethostbyname(self.ip), self.port),
|
||||||
)
|
)
|
||||||
self.packet_request.framecounter = (
|
self.packet_request.framecounter = (
|
||||||
int.from_bytes(self.packet_request.framecounter, "little") + 1
|
int.from_bytes(self.packet_request.framecounter, "little") + 1
|
||||||
).to_bytes(4, "little")
|
).to_bytes(4, "little")
|
||||||
|
self.logger.debug(f"sendtext: [{self.ip}:{self.port}] {script}")
|
||||||
time.sleep(self.DELAY)
|
time.sleep(self.DELAY)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -185,7 +180,6 @@ class VbanCmd(metaclass=ABCMeta):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(obj)
|
raise ValueError(obj)
|
||||||
|
|
||||||
self._script = str()
|
|
||||||
[param(key).apply(datum).then_wait() for key, datum in data.items()]
|
[param(key).apply(datum).then_wait() for key, datum in data.items()]
|
||||||
|
|
||||||
def apply_config(self, name):
|
def apply_config(self, name):
|
||||||
|
Loading…
Reference in New Issue
Block a user