File tree 2 files changed +7
-8
lines changed 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,6 @@ class Driver:
19
19
20
20
def __init__ (self , serial : str ):
21
21
self .serial = serial
22
- if not self ._is_device_online ():
23
- raise DeviceNotFoundError (f"Device [{ self .serial } ] not found" )
24
-
25
22
self ._client = HmClient (self .serial )
26
23
self .hdc = self ._client .hdc
27
24
@@ -46,10 +43,6 @@ def __del__(self):
46
43
def _init_hmclient (self ):
47
44
self ._client .start ()
48
45
49
- def _is_device_online (self ):
50
- _serials = list_devices ()
51
- return True if self .serial in _serials else False
52
-
53
46
def _invoke (self , api : str , args : List = []) -> HypiumResponse :
54
47
return self ._client .invoke (api , this = "Driver#0" , args = args )
55
48
Original file line number Diff line number Diff line change 11
11
from . import logger
12
12
from .utils import FreePort
13
13
from .proto import CommandResult , KeyCode
14
- from .exception import HdcError
14
+ from .exception import HdcError , DeviceNotFoundError
15
15
16
16
17
17
def _execute_command (cmdargs : Union [str , List [str ]]) -> CommandResult :
@@ -48,6 +48,12 @@ def list_devices() -> List[str]:
48
48
class HdcWrapper :
49
49
def __init__ (self , serial : str ) -> None :
50
50
self .serial = serial
51
+ if not self .is_online ():
52
+ raise DeviceNotFoundError (f"Device [{ self .serial } ] not found" )
53
+
54
+ def is_online (self ):
55
+ _serials = list_devices ()
56
+ return True if self .serial in _serials else False
51
57
52
58
def forward_port (self , rport : int ) -> int :
53
59
lport : int = FreePort ().get ()
You can’t perform that action at this time.
0 commit comments