]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py
3 Copyright (c) 2011-2013 ARM Limited
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
18 from shutil
import copy
19 from host_test_plugins
import HostTestPluginBase
22 class HostTestPluginCopyMethod_Mbed(HostTestPluginBase
):
24 def generic_mbed_copy(self
, image_path
, destination_disk
):
25 """ Generic mbed copy method for "mbed enabled" devices.
26 It uses standard python shuitl function to copy
27 image_file (target specific binary) to device's disk.
30 if not destination_disk
.endswith('/') and not destination_disk
.endswith('\\'):
31 destination_disk
+= '/'
33 copy(image_path
, destination_disk
)
35 self
.print_plugin_error("shutil.copy('%s', '%s')"% (image_path
, destination_disk
))
36 self
.print_plugin_error("Error: %s"% str(e
))
41 name
= 'HostTestPluginCopyMethod_Mbed'
44 capabilities
= ['default']
45 required_parameters
= ['image_path', 'destination_disk']
47 def setup(self
, *args
, **kwargs
):
48 """ Configure plugin, this function should be called before plugin execute() method is used.
52 def execute(self
, capabilitity
, *args
, **kwargs
):
53 """ Executes capability by name.
54 Each capability may directly just call some command line
55 program or execute building pythonic function
58 if self
.check_parameters(capabilitity
, *args
, **kwargs
) is True:
59 if capabilitity
== 'default':
60 image_path
= kwargs
['image_path']
61 destination_disk
= kwargs
['destination_disk']
62 # Wait for mount point to be ready
63 self
.check_mount_point_ready(destination_disk
) # Blocking
64 result
= self
.generic_mbed_copy(image_path
, destination_disk
)
69 """ Returns plugin available in this module
71 return HostTestPluginCopyMethod_Mbed()