File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change 1111from .descriptor import Descriptor
1212from .devices import __all__ as all_devs
1313
14- # Get the client for the device
15- def get_client (device_type , device_path , password = '' , expert = False ):
14+ def get_client_class (device_type ):
1615 device_type = device_type .split ('_' )[0 ]
1716 class_name = device_type .capitalize ()
1817 module = device_type .lower ()
1918
20- client = None
2119 try :
2220 imported_dev = importlib .import_module ('.devices.' + module , __package__ )
2321 client_constructor = getattr (imported_dev , class_name + 'Client' )
24- client = client_constructor (device_path , password , expert )
2522 except ImportError :
23+ raise UnknownDeviceError ('Unknown device type specified' )
24+
25+ return client_constructor
26+
27+ # Get the client for the device
28+ def get_client (device_type , device_path , password = '' , expert = False ):
29+ client = None
30+ try :
31+ client_constructor = get_client_class (device_type )
32+ client = client_constructor (device_path , password , expert )
33+ except :
2634 if client :
2735 client .close ()
28- raise UnknownDeviceError ( 'Unknown device type specified' )
36+ raise
2937
3038 return client
3139
You can’t perform that action at this time.
0 commit comments