From 7ff8aa1ba0cc51c291a9279c7749ff8186d88cf3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 11 May 2023 12:32:38 -0400 Subject: [PATCH] ib: passthrough host arg to vnc client for click hack --- piker/brokers/ib/_util.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/piker/brokers/ib/_util.py b/piker/brokers/ib/_util.py index a94f77f1..114022fa 100644 --- a/piker/brokers/ib/_util.py +++ b/piker/brokers/ib/_util.py @@ -19,13 +19,21 @@ runnable script-programs. ''' -from typing import Literal +from __future__ import annotations +from functools import partial +from typing import ( + Literal, + TYPE_CHECKING, +) import subprocess import tractor from .._util import log +if TYPE_CHECKING: + from .api import MethodProxy + _reset_tech: Literal[ 'vnc', @@ -39,7 +47,9 @@ _reset_tech: Literal[ async def data_reset_hack( + proxy: MethodProxy, reset_type: str = 'data', + **kwargs, ) -> None: ''' @@ -71,10 +81,17 @@ async def data_reset_hack( ''' global _reset_tech + client: 'IBCLIENTTHING' = proxy._aio_ns.ib.client + match _reset_tech: case 'vnc': try: - await tractor.to_asyncio.run_task(vnc_click_hack) + await tractor.to_asyncio.run_task( + partial( + vnc_click_hack, + host=client.host, + ) + ) except OSError: _reset_tech = 'i3ipc_xdotool' try: @@ -94,10 +111,11 @@ async def data_reset_hack( async def vnc_click_hack( + host: str = 'localhost', reset_type: str = 'data' ) -> None: ''' - Reset the data or netowork connection for the VNC attached + Reset the data or network connection for the VNC attached ib gateway using magic combos. ''' @@ -106,7 +124,7 @@ async def vnc_click_hack( import asyncvnc async with asyncvnc.connect( - 'localhost', + host, port=3003, # password='ibcansmbz', ) as client: