mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 12:50:53 +00:00
update readme and base client
This commit is contained in:
parent
15559fdb33
commit
64a7c2b753
@ -27,7 +27,7 @@ By default the clients connect with parameters:
|
|||||||
- `host`: "localhost"
|
- `host`: "localhost"
|
||||||
- `port`: 4455
|
- `port`: 4455
|
||||||
- `password`: ""
|
- `password`: ""
|
||||||
- `timeout`: 3
|
|
||||||
You may override these parameters by storing them in a toml config file or passing them as keyword arguments.
|
You may override these parameters by storing them in a toml config file or passing them as keyword arguments.
|
||||||
|
|
||||||
Order of precedence: keyword arguments then config file then default values.
|
Order of precedence: keyword arguments then config file then default values.
|
||||||
|
@ -7,7 +7,7 @@ from random import randint
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import websocket
|
import websocket
|
||||||
|
from websocket._exceptions import WebSocketTimeoutException
|
||||||
from .error import OBSSDKError
|
from .error import OBSSDKError
|
||||||
|
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ class ObsClient:
|
|||||||
logger = logging.getLogger("baseclient.obsclient")
|
logger = logging.getLogger("baseclient.obsclient")
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0, "timeout":3}
|
defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0, "timeout":None}
|
||||||
if not any(key in kwargs for key in ("host", "port", "password")):
|
if not any(key in kwargs for key in ("host", "port", "password")):
|
||||||
kwargs |= self._conn_from_toml()
|
kwargs |= self._conn_from_toml()
|
||||||
kwargs = defaultkwargs | kwargs
|
kwargs = defaultkwargs | kwargs
|
||||||
@ -107,8 +107,8 @@ class ObsClient:
|
|||||||
self.logger.debug(f"Sending request {payload}")
|
self.logger.debug(f"Sending request {payload}")
|
||||||
try:
|
try:
|
||||||
self.ws.send(json.dumps(payload))
|
self.ws.send(json.dumps(payload))
|
||||||
except TimeoutError:
|
|
||||||
raise OBSSDKError("Timeout while trying to send the request")
|
|
||||||
response = json.loads(self.ws.recv())
|
response = json.loads(self.ws.recv())
|
||||||
|
except WebSocketTimeoutException :
|
||||||
|
raise OBSSDKError("Timeout while trying to send the request")
|
||||||
self.logger.debug(f"Response received {response}")
|
self.logger.debug(f"Response received {response}")
|
||||||
return response["d"]
|
return response["d"]
|
||||||
|
Loading…
Reference in New Issue
Block a user