From 598654fa4d705c1acfd62904474b47ace26825a5 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 14 Aug 2015 11:57:01 +0100 Subject: [PATCH 1/3] Changed 'default' flashing method for cli option -c to 'shell' --- workspace_tools/host_tests/host_test.py | 11 +++++++---- .../host_tests/host_tests_plugins/module_copy_mbed.py | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/workspace_tools/host_tests/host_test.py b/workspace_tools/host_tests/host_test.py index 4dd16505a2..d11a40de4d 100644 --- a/workspace_tools/host_tests/host_test.py +++ b/workspace_tools/host_tests/host_test.py @@ -250,12 +250,15 @@ class Mbed: """ Copy file depending on method you want to use. Handles exception and return code from shell copy commands. """ + # image_path - Where is binary with target's firmware if copy_method is not None: - # image_path - Where is binary with target's firmware - result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk) + # We override 'default' method with 'shell' method + if copy_method == 'default': + copy_method = 'shell' else: - copy_method = 'default' - result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk) + copy_method = 'shell' + + result = host_tests_plugins.call_plugin('CopyMethod', copy_method, image_path=image_path, destination_disk=disk) return result; def flush(self): diff --git a/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py b/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py index 18fe0c42ae..14e88188bc 100644 --- a/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py +++ b/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py @@ -41,7 +41,7 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase): name = 'HostTestPluginCopyMethod_Mbed' type = 'CopyMethod' stable = True - capabilities = ['default'] + capabilities = ['shutil', 'default'] required_parameters = ['image_path', 'destination_disk'] def setup(self, *args, **kwargs): @@ -56,7 +56,8 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase): """ result = False if self.check_parameters(capabilitity, *args, **kwargs) is True: - if capabilitity == 'default': + # Capability 'default' is a dummy capability + if capability == 'shutil': image_path = kwargs['image_path'] destination_disk = kwargs['destination_disk'] # Wait for mount point to be ready From 074809da0fe1eb3115f6f1b2d733be6b1b0c6920 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 14 Aug 2015 14:41:52 +0100 Subject: [PATCH 2/3] fixed typo capabilitity -> capability --- .../host_tests/host_tests_plugins/module_copy_mbed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py b/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py index 14e88188bc..2b9527e95f 100644 --- a/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py +++ b/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py @@ -49,13 +49,13 @@ class HostTestPluginCopyMethod_Mbed(HostTestPluginBase): """ return True - def execute(self, capabilitity, *args, **kwargs): + def execute(self, capability, *args, **kwargs): """ Executes capability by name. Each capability may directly just call some command line program or execute building pythonic function """ result = False - if self.check_parameters(capabilitity, *args, **kwargs) is True: + if self.check_parameters(capability, *args, **kwargs) is True: # Capability 'default' is a dummy capability if capability == 'shutil': image_path = kwargs['image_path'] From 2875d4bffa97ae18632a7568043594dbe4e655bc Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Fri, 14 Aug 2015 14:53:50 +0100 Subject: [PATCH 3/3] Added 'sync' command after shell copy execution for posix OS --- .../host_tests_plugins/module_copy_shell.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py b/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py index 8e5e4153e0..dbbc7365c0 100644 --- a/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py +++ b/workspace_tools/host_tests/host_tests_plugins/module_copy_shell.py @@ -34,13 +34,13 @@ class HostTestPluginCopyMethod_Shell(HostTestPluginBase): """ return True - def execute(self, capabilitity, *args, **kwargs): + def execute(self, capability, *args, **kwargs): """ Executes capability by name. Each capability may directly just call some command line program or execute building pythonic function """ result = False - if self.check_parameters(capabilitity, *args, **kwargs) is True: + if self.check_parameters(capability, *args, **kwargs) is True: image_path = kwargs['image_path'] destination_disk = kwargs['destination_disk'] # Wait for mount point to be ready @@ -48,14 +48,17 @@ class HostTestPluginCopyMethod_Shell(HostTestPluginBase): # Prepare correct command line parameter values image_base_name = basename(image_path) destination_path = join(destination_disk, image_base_name) - if capabilitity == 'shell': - if os.name == 'nt': capabilitity = 'copy' - elif os.name == 'posix': capabilitity = 'cp' - if capabilitity == 'cp' or capabilitity == 'copy' or capabilitity == 'xcopy': - copy_method = capabilitity + if capability == 'shell': + if os.name == 'nt': capability = 'copy' + elif os.name == 'posix': capability = 'cp' + if capability == 'cp' or capability == 'copy' or capability == 'copy': + copy_method = capability cmd = [copy_method, image_path, destination_path] - shell = not capabilitity == 'cp' - result = self.run_command(cmd, shell=shell) + if os.name == 'posix': + result = self.run_command(cmd, shell=False) + result = self.run_command(["sync"]) + else: + result = self.run_command(cmd) return result