]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/workspace_tools/host_tests/host_tests_plugins/module_copy_mbed.py
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / workspace_tools / host_tests / host_tests_plugins / module_copy_mbed.py
1 """
2 mbed SDK
3 Copyright (c) 2011-2013 ARM Limited
4
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
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
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.
16 """
17
18 from shutil import copy
19 from host_test_plugins import HostTestPluginBase
20
21
22 class HostTestPluginCopyMethod_Mbed(HostTestPluginBase):
23
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.
28 """
29 result = True
30 if not destination_disk.endswith('/') and not destination_disk.endswith('\\'):
31 destination_disk += '/'
32 try:
33 copy(image_path, destination_disk)
34 except Exception, e:
35 self.print_plugin_error("shutil.copy('%s', '%s')"% (image_path, destination_disk))
36 self.print_plugin_error("Error: %s"% str(e))
37 result = False
38 return result
39
40 # Plugin interface
41 name = 'HostTestPluginCopyMethod_Mbed'
42 type = 'CopyMethod'
43 stable = True
44 capabilities = ['default']
45 required_parameters = ['image_path', 'destination_disk']
46
47 def setup(self, *args, **kwargs):
48 """ Configure plugin, this function should be called before plugin execute() method is used.
49 """
50 return True
51
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
56 """
57 result = False
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)
65 return result
66
67
68 def load_plugin():
69 """ Returns plugin available in this module
70 """
71 return HostTestPluginCopyMethod_Mbed()
Imprint / Impressum