From 92e2c29bd6ffe51889b4db8b5995234b1d4c37f9 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 5 Dec 2022 16:39:33 +0000 Subject: [PATCH 1/5] enum.py renamed to subs.py. No changes to file contents. relative import changed in __init__.py --- obsws_python/__init__.py | 2 +- obsws_python/{enum.py => subs.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename obsws_python/{enum.py => subs.py} (100%) diff --git a/obsws_python/__init__.py b/obsws_python/__init__.py index 80251d6..b0e6d73 100644 --- a/obsws_python/__init__.py +++ b/obsws_python/__init__.py @@ -1,6 +1,6 @@ -from .enum import Subs from .events import EventClient from .reqs import ReqClient +from .subs import Subs from .version import version as __version__ __ALL__ = ["ReqClient", "EventClient", "Subs"] diff --git a/obsws_python/enum.py b/obsws_python/subs.py similarity index 100% rename from obsws_python/enum.py rename to obsws_python/subs.py From cf888b0c4a20cba1c1a60a317cc530f71be7a0f9 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 5 Dec 2022 16:41:34 +0000 Subject: [PATCH 2/5] conn paramters added to __repr__ magic methods add __str__ override (used in logger) --- obsws_python/events.py | 7 ++++++- obsws_python/reqs.py | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/obsws_python/events.py b/obsws_python/events.py index 0771e26..f281340 100644 --- a/obsws_python/events.py +++ b/obsws_python/events.py @@ -5,7 +5,7 @@ from threading import Thread from .baseclient import ObsClient from .callback import Callback -from .enum import Subs +from .subs import Subs """ A class to interact with obs-websocket events @@ -28,6 +28,11 @@ class EventClient: self.subscribe() def __repr__(self): + return type(self).__name__ + "({host} {port} {password} {subs})".format( + **self.base_client.__dict__ + ) + + def __str__(self): return type(self).__name__ def subscribe(self): diff --git a/obsws_python/reqs.py b/obsws_python/reqs.py index 58dc888..4771092 100644 --- a/obsws_python/reqs.py +++ b/obsws_python/reqs.py @@ -26,6 +26,11 @@ class ReqClient: self.base_client.ws.close() def __repr__(self): + return type(self).__name__ + "({host} {port} {password})".format( + **self.base_client.__dict__ + ) + + def __str__(self): return type(self).__name__ def send(self, param, data=None, raw=False): From 41b0dfbe4b38862c50eea7214f8c7a10698cdf76 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 5 Dec 2022 16:43:07 +0000 Subject: [PATCH 3/5] ensure studio mode is disabled at end of test run --- tests/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/__init__.py b/tests/__init__.py index b1e7d9c..a20f785 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -13,4 +13,7 @@ def teardown_module(): req_cl.remove_scene("START_TEST") req_cl.remove_scene("BRB_TEST") req_cl.remove_scene("END_TEST") + resp = req_cl.get_studio_mode_enabled() + if resp.studio_mode_enabled: + req_cl.set_studio_mode_enabled(False) req_cl.base_client.ws.close() From cc9b1e2c724d010bb36ef2ae1f564734b3cc42de Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 5 Dec 2022 16:49:17 +0000 Subject: [PATCH 4/5] lower min python required version to 3.9 python ver test matrix added to hatch config minor version bump --- README.md | 3 +-- obsws_python/version.py | 2 +- pyproject.toml | 21 ++++++++++++++++----- setup.py | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fb39ca5..9528a27 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ # A Python SDK for OBS Studio WebSocket v5.0 -This is a wrapper around OBS Websocket. Not all endpoints in the official documentation are implemented. ## Requirements @@ -13,7 +12,7 @@ Not all endpoints in the official documentation are implemented. - [OBS Studio](https://obsproject.com/) - [OBS Websocket v5 Plugin](https://github.com/obsproject/obs-websocket/releases/tag/5.0.0) - With the release of OBS Studio version 28, Websocket plugin is included by default. But it should be manually installed for earlier versions of OBS. -- Python 3.10 or greater +- Python 3.9 or greater ### How to install using pip diff --git a/obsws_python/version.py b/obsws_python/version.py index d28b3dd..d619c75 100644 --- a/obsws_python/version.py +++ b/obsws_python/version.py @@ -1 +1 @@ -version = "1.3.0" +version = "1.4.0" diff --git a/pyproject.toml b/pyproject.toml index 812c68a..287fdf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ dynamic = ["version"] description = "A Python SDK for OBS Studio WebSocket v5.0" readme = "README.md" license = "GPL-3.0-only" -requires-python = ">=3.10" +requires-python = ">=3.9" authors = [ { name = "Adem Atikturk", email = "aatikturk@gmail.com" }, ] @@ -37,7 +37,18 @@ include = [ ] [tool.hatch.envs.e.scripts] -events = "py {root}\\examples\\events\\." -hotkeys = "py {root}\\examples\\hotkeys\\." -levels = "py {root}\\examples\\levels\\." -scene_rotate = "py {root}\\examples\\scene_rotate\\." +events = "python {root}\\examples\\events\\." +hotkeys = "python {root}\\examples\\hotkeys\\." +levels = "python {root}\\examples\\levels\\." +scene_rotate = "python {root}\\examples\\scene_rotate\\." + +[tool.hatch.envs.test] +dependencies = [ + "pytest", +] + +[tool.hatch.envs.test.scripts] +run = 'pytest -v' + +[[tool.hatch.envs.test.matrix]] +python = ["39", "310", "311"] diff --git a/setup.py b/setup.py index 4b369e1..b157c07 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ EXTRAS_REQUIRE = { } # Python version requirement -PYTHON_REQUIRES = ">=3.10" +PYTHON_REQUIRES = ">=3.9" setup( name=PACKAGE_NAME, From 48e90c82fba8cdd41bf5dd1e1ea804f27d4712f5 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Mon, 5 Dec 2022 18:18:10 +0000 Subject: [PATCH 5/5] alter format of __repr__ in Req + Event clients password now defaults to empty string, not None. --- README.md | 2 +- obsws_python/baseclient.py | 4 ++-- obsws_python/events.py | 6 ++++-- obsws_python/reqs.py | 6 ++++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9528a27..b1d2a44 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ By default the clients connect with parameters: - `host`: "localhost" - `port`: 4455 -- `password`: None +- `password`: "" You may override these parameters by storing them in a toml config file or passing them as keyword arguments. diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index 273e96b..e1dfc52 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -14,7 +14,7 @@ class ObsClient: logger = logging.getLogger("baseclient.obsclient") def __init__(self, **kwargs): - defaultkwargs = {"host": "localhost", "port": 4455, "password": None, "subs": 0} + defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0} if not any(key in kwargs for key in ("host", "port", "password")): kwargs |= self._conn_from_toml() kwargs = defaultkwargs | kwargs @@ -22,7 +22,7 @@ class ObsClient: setattr(self, attr, val) self.logger.info( - "Connecting with parameters: {host} {port} {password} {subs}".format( + "Connecting with parameters: host='{host}' port={port} password='{password}' subs={subs}".format( **self.__dict__ ) ) diff --git a/obsws_python/events.py b/obsws_python/events.py index f281340..9a942e6 100644 --- a/obsws_python/events.py +++ b/obsws_python/events.py @@ -28,8 +28,10 @@ class EventClient: self.subscribe() def __repr__(self): - return type(self).__name__ + "({host} {port} {password} {subs})".format( - **self.base_client.__dict__ + return type( + self + ).__name__ + "(host='{host}', port={port}, password='{password}', subs={subs})".format( + **self.base_client.__dict__, ) def __str__(self): diff --git a/obsws_python/reqs.py b/obsws_python/reqs.py index 4771092..f823431 100644 --- a/obsws_python/reqs.py +++ b/obsws_python/reqs.py @@ -26,8 +26,10 @@ class ReqClient: self.base_client.ws.close() def __repr__(self): - return type(self).__name__ + "({host} {port} {password})".format( - **self.base_client.__dict__ + return type( + self + ).__name__ + "(host='{host}', port={port}, password='{password}')".format( + **self.base_client.__dict__, ) def __str__(self):