Skip to content

Commit a7ff348

Browse files
author
CoolUsername
committed
CR: Remove stdout. replace logging function
1 parent 874ed49 commit a7ff348

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

src/mbed_os_tools/test/host_tests_plugins/host_test_plugins.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,18 +221,17 @@ def check_parameters(self, capability, *args, **kwargs):
221221
return False
222222
return True
223223

224-
def run_command(self, cmd, shell=True, stdin = None, stdout = None):
224+
def run_command(self, cmd, shell=True, stdin = None):
225225
"""! Runs command from command line.
226226
@param cmd Command to execute
227227
@param shell True if shell command should be executed (eg. ls, ps)
228228
@param stdin A custom stdin for the process running the command (defaults to None)
229-
@param stdout A custom stdout for the process running the command (defaults to None)
230229
@details Function prints 'cmd' return code if execution failed
231230
@return True if command successfully executed
232231
"""
233232
result = True
234233
try:
235-
ret = call(cmd, shell=shell, stdin=stdin, stdout=stdout)
234+
ret = call(cmd, shell=shell, stdin=stdin)
236235
if ret:
237236
self.print_plugin_error("[ret=%d] Command: %s"% (int(ret), cmd))
238237
return False

src/mbed_os_tools/test/host_tests_plugins/module_reset_stlink.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import sys
1818
import tempfile
1919
from .host_test_plugins import HostTestPluginBase
20-
from .host_tests_logger import HtrunLogger
2120

2221
FIX_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

Comments
 (0)