3 Copyright (c) 2011-2015 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.
17 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
21 from shutil
import copy
22 from .host_test_plugins
import HostTestPluginBase
26 """ Generic flashing method for mbed-enabled devices (by copy)
32 HostTestPluginBase.__init__(self)
35 """! Generic mbed copy method for "mbed enabled" devices.
37 @param image_path Path to binary file to be flashed
38 @param destination_disk Path to destination (mbed mount point)
40 @details It uses standard python shutil function to copy image_file (target specific binary) to device's disk.
42 @return Returns True if copy (flashing) was successful
45 if not destination_disk.endswith(
'/')
and not destination_disk.endswith(
'\\'):
46 destination_disk +=
'/'
48 copy(image_path, destination_disk)
49 except Exception
as e:
56 name =
'HostTestPluginCopyMethod_Mbed'
59 capabilities = [
'shutil',
'default']
60 required_parameters = [
'image_path',
'destination_disk']
62 def setup(self, *args, **kwargs):
63 """ Configure plugin, this function should be called before plugin execute() method is used.
67 def execute(self, capability, *args, **kwargs):
68 """! Executes capability by name.
69 @details Each capability may directly just call some command line program or execute building pythonic function
70 @return Returns True if 'capability' operation was successful
72 if not kwargs[
'image_path']:
76 if not kwargs[
'destination_disk']:
81 target_id = kwargs.get(
'target_id',
None)
82 pooling_timeout = kwargs.get(
'polling_timeout', 60)
87 if kwargs[
'image_path']
and kwargs[
'destination_disk']:
88 if capability ==
'shutil':
89 image_path = os.path.normpath(kwargs[
'image_path'])
90 destination_disk = os.path.normpath(kwargs[
'destination_disk'])
94 mount_res, destination_disk = self.
check_mount_point_ready(destination_disk, target_id=self.target_id, timeout=pooling_timeout)
101 """ Returns plugin available in this module