1717import sys
1818import tempfile
1919from .host_test_plugins import HostTestPluginBase
20- from .host_tests_logger import HtrunLogger
2120
2221FIX_FILE_NAME = "enter_file.txt"
2322
@@ -51,7 +50,6 @@ def is_os_supported(self, os_name=None):
5150 def setup (self , * args , ** kwargs ):
5251 """! Configure plugin, this function should be called before plugin execute() method is used.
5352 """
54- self .logger = HtrunLogger ('STLINK_RESET_PLUGIN' )
5553 # Note you need to have eACommander.exe on your system path!
5654 self .ST_LINK_CLI = 'ST-LINK_CLI.exe'
5755 return True
@@ -66,7 +64,7 @@ def create_stlink_fix_file(self, file_path):
6664 with open (file_path , "w" ) as fix_file :
6765 fix_file .write (os .linesep )
6866 except (OSError , IOError ):
69- self .logger . prn_err ("Error opening STLINK-PRESS-ENTER-BUG file" )
67+ self .print_plugin_error ("Error opening STLINK-PRESS-ENTER-BUG file" )
7068 sys .exit (1 )
7169
7270
@@ -95,16 +93,11 @@ def execute(self, capability, *args, **kwargs):
9593 enter_file_path = os .path .join (tempfile .gettempdir (), FIX_FILE_NAME )
9694 self .create_stlink_fix_file (enter_file_path )
9795 try :
98- with open (enter_fix_file , 'r' ) as fix_file :
99- std_args = {'stdin' : fix_file }
100- if 'stdin' in kwargs :
101- std_args ['stdin' ] = kwargs ['stdin' ]
102- if 'stdout' in kwargs :
103- std_args ['stdout' ] = kwargs ['stdout' ]
104-
105- result = self .run_command (cmd , ** std_args )
96+ with open (enter_file_path , 'r' ) as fix_file :
97+ stdin_arg = kwargs .get ('stdin' , fix_file )
98+ result = self .run_command (cmd , stdin = stdin_arg )
10699 except (OSError , IOError ):
107- self .logger . prn_err ("Error opening STLINK-PRESS-ENTER-BUG file" )
100+ self .print_plugin_error ("Error opening STLINK-PRESS-ENTER-BUG file" )
108101 sys .exit (1 )
109102
110103 return result
0 commit comments