Skip to content

Commit 7d61c8d

Browse files
committed
match changes in hyperion-py-0.7.5
1 parent 3810c53 commit 7d61c8d

4 files changed

Lines changed: 119 additions & 122 deletions

File tree

hyperhdr/client.py

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
Dict,
2424
Iterable,
2525
Mapping,
26-
Type,
2726
Union,
2827
cast,
2928
)
@@ -92,9 +91,8 @@ def __init__(
9291
self,
9392
host: str,
9493
port: int = const.DEFAULT_PORT_JSON,
95-
default_callback: Union[HyperHDRCallback, Iterable[HyperHDRCallback]]
96-
| None = None,
97-
callbacks: Mapping[str, Union[HyperHDRCallback, Iterable[HyperHDRCallback]]]
94+
default_callback: HyperHDRCallback | Iterable[HyperHDRCallback] | None = None,
95+
callbacks: Mapping[str, HyperHDRCallback | Iterable[HyperHDRCallback]]
9896
| None = None,
9997
token: str | None = None,
10098
instance: int = const.DEFAULT_INSTANCE,
@@ -153,7 +151,7 @@ async def __aenter__(self) -> "HyperHDRClient" | None:
153151

154152
async def __aexit__(
155153
self,
156-
exc_type: Type[BaseException] | None,
154+
exc_type: type[BaseException] | None,
157155
exc: BaseException | None,
158156
traceback: TracebackType | None,
159157
) -> None:
@@ -177,7 +175,7 @@ async def _client_state_reset(self) -> None:
177175
@classmethod
178176
def _set_or_add_callbacks(
179177
cls,
180-
callbacks: Union[HyperHDRCallback, Iterable[HyperHDRCallback]] | None,
178+
callbacks: HyperHDRCallback | Iterable[HyperHDRCallback] | None,
181179
add: bool,
182180
target: list[HyperHDRCallback],
183181
) -> None:
@@ -194,7 +192,7 @@ def _set_or_add_callbacks(
194192
@classmethod
195193
def _remove_callbacks(
196194
cls,
197-
callbacks: Union[HyperHDRCallback, Iterable[HyperHDRCallback]],
195+
callbacks: HyperHDRCallback | Iterable[HyperHDRCallback],
198196
target: list[HyperHDRCallback],
199197
) -> None:
200198
"""Set or add a single or list of callbacks."""
@@ -209,8 +207,7 @@ def _remove_callbacks(
209207

210208
def set_callbacks(
211209
self,
212-
callbacks: Mapping[str, Union[HyperHDRCallback, Iterable[HyperHDRCallback]]]
213-
| None,
210+
callbacks: Mapping[str, HyperHDRCallback | Iterable[HyperHDRCallback]] | None,
214211
) -> None:
215212
"""Set update callbacks."""
216213
if not callbacks:
@@ -223,7 +220,7 @@ def set_callbacks(
223220

224221
def add_callbacks(
225222
self,
226-
callbacks: Mapping[str, Union[HyperHDRCallback, Iterable[HyperHDRCallback]]],
223+
callbacks: Mapping[str, HyperHDRCallback | Iterable[HyperHDRCallback]],
227224
) -> None:
228225
"""Add update callbacks."""
229226
if not callbacks:
@@ -235,7 +232,7 @@ def add_callbacks(
235232

236233
def remove_callbacks(
237234
self,
238-
callbacks: Mapping[str, Union[HyperHDRCallback, Iterable[HyperHDRCallback]]],
235+
callbacks: Mapping[str, HyperHDRCallback | Iterable[HyperHDRCallback]],
239236
) -> None:
240237
"""Add update callbacks."""
241238
if not callbacks:
@@ -247,7 +244,7 @@ def remove_callbacks(
247244

248245
def set_default_callback(
249246
self,
250-
default_callback: Union[HyperHDRCallback, Iterable[HyperHDRCallback]] | None,
247+
default_callback: HyperHDRCallback | Iterable[HyperHDRCallback] | None,
251248
) -> None:
252249
"""Set the default callbacks."""
253250
HyperHDRClient._set_or_add_callbacks(
@@ -256,7 +253,7 @@ def set_default_callback(
256253

257254
def add_default_callback(
258255
self,
259-
default_callback: Union[HyperHDRCallback, Iterable[HyperHDRCallback]],
256+
default_callback: HyperHDRCallback | Iterable[HyperHDRCallback],
260257
) -> None:
261258
"""Set the default callbacks."""
262259
HyperHDRClient._set_or_add_callbacks(
@@ -265,7 +262,7 @@ def add_default_callback(
265262

266263
def remove_default_callback(
267264
self,
268-
default_callback: Union[HyperHDRCallback, Iterable[HyperHDRCallback]],
265+
default_callback: HyperHDRCallback | Iterable[HyperHDRCallback],
269266
) -> None:
270267
"""Set the default callbacks."""
271268
HyperHDRClient._remove_callbacks(default_callback, self._default_callback)
@@ -314,6 +311,16 @@ def client_state(self) -> dict[str, Any]:
314311
"""Return client state."""
315312
return self._client_state.get_all()
316313

314+
@property
315+
def host(self) -> str:
316+
"""Return host ip."""
317+
return self._host
318+
319+
@property
320+
def remote_url(self) -> str:
321+
"""Return remote control URL."""
322+
return f"http://{self._host}:{const.DEFAULT_PORT_UI}/#remote"
323+
317324
async def async_client_connect(self) -> bool:
318325
"""Connect to the HyperHDR server."""
319326

@@ -813,7 +820,7 @@ def __init__(
813820
self._timeout_secs = timeout_secs
814821

815822
def _extract_timeout_secs(
816-
self, hyperhdr_client: "HyperHDRClient", data: dict[str, Any]
823+
self, hyperhdr_client: HyperHDRClient, data: dict[str, Any]
817824
) -> float:
818825
"""Return the timeout value for a call.
819826
@@ -840,7 +847,7 @@ async def __call__(
840847
# The receive task should never be executing a call that uses the
841848
# AwaitResponseWrapper (as the response is itself handled by the receive
842849
# task, i.e. partial deadlock). This assertion defends against programmer
843-
# error in development of the client iself.
850+
# error in development of the client itself.
844851
assert asyncio.current_task() != hyperhdr_client._receive_task
845852

846853
tan = await hyperhdr_client._reserve_tan_slot(kwargs.get(const.KEY_TAN))
@@ -856,8 +863,8 @@ async def __call__(
856863
return response
857864

858865
def __get__(
859-
self, instance: "HyperHDRClient", instancetype: Type["HyperHDRClient"]
860-
) -> "functools.partial[Coroutine[Any, Any, dict[str, Any] | None]]":
866+
self, instance: HyperHDRClient, instancetype: type[HyperHDRClient]
867+
) -> functools.partial[Coroutine[Any, Any, dict[str, Any] | None]]:
861868
"""Return a partial call that uses the correct 'self'."""
862869
# Need to ensure __call__ receives the 'correct' outer
863870
# 'self', which is 'instance' in this function.
@@ -1500,9 +1507,8 @@ def __init__(
15001507
self,
15011508
host: str,
15021509
port: int = const.DEFAULT_PORT_JSON,
1503-
default_callback: Union[HyperHDRCallback, Iterable[HyperHDRCallback]]
1504-
| None = None,
1505-
callbacks: dict[str, Union[HyperHDRCallback, Iterable[HyperHDRCallback]]]
1510+
default_callback: HyperHDRCallback | Iterable[HyperHDRCallback] | None = None,
1511+
callbacks: dict[str, HyperHDRCallback | Iterable[HyperHDRCallback]]
15061512
| None = None,
15071513
token: str | None = None,
15081514
instance: int = const.DEFAULT_INSTANCE,
@@ -1665,4 +1671,4 @@ def generate_random_auth_id() -> str:
16651671
"""Generate random authenticate ID."""
16661672
return "".join(
16671673
random.choice(string.ascii_letters + string.digits) for i in range(0, 5)
1668-
)
1674+
)

hyperhdr/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,4 @@
121121
DEFAULT_REQUEST_TOKEN_TIMEOUT_SECS = 180
122122
DEFAULT_ORIGIN = "hyperhdr-py"
123123
DEFAULT_PORT_JSON = 19444
124-
DEFAULT_PORT_UI = 8090
124+
DEFAULT_PORT_UI = 8090

0 commit comments

Comments
 (0)