17
17
import sys
18
18
import tempfile
19
19
from .host_test_plugins import HostTestPluginBase
20
- from .host_tests_logger import HtrunLogger
21
20
22
21
FIX_FILE_NAME = "enter_file.txt"
23
22
@@ -51,7 +50,6 @@ def is_os_supported(self, os_name=None):
51
50
def setup (self , * args , ** kwargs ):
52
51
"""! Configure plugin, this function should be called before plugin execute() method is used.
53
52
"""
54
- self .logger = HtrunLogger ('STLINK_RESET_PLUGIN' )
55
53
# Note you need to have eACommander.exe on your system path!
56
54
self .ST_LINK_CLI = 'ST-LINK_CLI.exe'
57
55
return True
@@ -66,7 +64,7 @@ def create_stlink_fix_file(self, file_path):
66
64
with open (file_path , "w" ) as fix_file :
67
65
fix_file .write (os .linesep )
68
66
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" )
70
68
sys .exit (1 )
71
69
72
70
@@ -95,16 +93,11 @@ def execute(self, capability, *args, **kwargs):
95
93
enter_file_path = os .path .join (tempfile .gettempdir (), FIX_FILE_NAME )
96
94
self .create_stlink_fix_file (enter_file_path )
97
95
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 )
106
99
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" )
108
101
sys .exit (1 )
109
102
110
103
return result
0 commit comments