3Copyright (c) 2011-2015 ARM Limited
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
17Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
21from shutil
import copy
22from .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
Base class for all plugins used with host tests.
check_mount_point_ready(self, destination_disk, init_delay=0.2, loop_delay=0.25, target_id=None, timeout=60)
Waits until destination_disk is ready and can be accessed by e.g.
print_plugin_error(self, text)
Interface helper methods - overload only if you need to have custom behaviour.
check_parameters(self, capability, *args, **kwargs)
This function should be ran each time we call execute() to check if none of the required parameters i...
setup(self, *args, **kwargs)
generic_mbed_copy(self, image_path, destination_disk)
Generic mbed copy method for "mbed enabled" devices.
execute(self, capability, *args, **kwargs)
Executes capability by name.