mirror of
https://github.com/onyx-and-iris/vban-cmd-python.git
synced 2024-11-15 17:10:46 +00:00
raise VBANCMD error on connection failure.
leave teardown procedures to consumer library. (or context manager)
This commit is contained in:
parent
444f95a9d6
commit
733fab45b4
@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "vban-cmd"
|
name = "vban-cmd"
|
||||||
version = "1.4.3"
|
version = "1.4.4"
|
||||||
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"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
from .error import VMCMDErrors
|
|
||||||
from .iremote import IRemote
|
from .iremote import IRemote
|
||||||
from .meta import action_prop
|
from .meta import action_prop
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class VMCMDErrors(Exception):
|
class VBANCMDError(Exception):
|
||||||
"""general errors"""
|
"""general errors"""
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from .error import VMCMDErrors
|
|
||||||
from .util import cache_bool, cache_string
|
from .util import cache_bool, cache_string
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ import threading
|
|||||||
import time
|
import time
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
from .error import VBANCMDError
|
||||||
from .packet import HEADER_SIZE, SubscribeHeader, VbanRtPacket, VbanRtPacketHeader
|
from .packet import HEADER_SIZE, SubscribeHeader, VbanRtPacket, VbanRtPacketHeader
|
||||||
from .util import Socket
|
from .util import Socket
|
||||||
|
|
||||||
@ -26,9 +27,9 @@ class Subscriber(threading.Thread):
|
|||||||
self.packet.framecounter = count.to_bytes(4, "little")
|
self.packet.framecounter = count.to_bytes(4, "little")
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
except socket.gaierror as e:
|
except socket.gaierror as e:
|
||||||
print(f"Unable to resolve hostname {self._remote.ip}")
|
err_msg = f"Unable to resolve hostname {self._remote.ip}"
|
||||||
self._remote.socks[Socket.register].close()
|
print(err_msg)
|
||||||
raise e
|
raise VBANCMDError(err_msg)
|
||||||
|
|
||||||
|
|
||||||
class Updater(threading.Thread):
|
class Updater(threading.Thread):
|
||||||
@ -80,9 +81,9 @@ class Updater(threading.Thread):
|
|||||||
_busLabelUTF8c60=data[932:1412],
|
_busLabelUTF8c60=data[932:1412],
|
||||||
)
|
)
|
||||||
except TimeoutError as e:
|
except TimeoutError as e:
|
||||||
print(f"Unable to establish connection with {self._remote.ip}")
|
err_msg = f"Unable to establish connection with {self._remote.ip}"
|
||||||
[sock.close() for sock in self._remote.socks]
|
print(err_msg)
|
||||||
raise e
|
raise VBANCMDError(err_msg)
|
||||||
|
|
||||||
def _get_rt(self) -> VbanRtPacket:
|
def _get_rt(self) -> VbanRtPacket:
|
||||||
"""Attempt to fetch data packet until a valid one found"""
|
"""Attempt to fetch data packet until a valid one found"""
|
||||||
|
Loading…
Reference in New Issue
Block a user