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 os.path
import join, basename
22 from .host_test_plugins
import HostTestPluginBase
27 name =
'HostTestPluginCopyMethod_Shell'
30 capabilities = [
'shell',
'cp',
'copy',
'xcopy']
31 required_parameters = [
'image_path',
'destination_disk']
36 HostTestPluginBase.__init__(self)
38 def setup(self, *args, **kwargs):
39 """ Configure plugin, this function should be called before plugin execute() method is used.
43 def execute(self, capability, *args, **kwargs):
44 """! Executes capability by name
46 @param capability Capability name
47 @param args Additional arguments
48 @param kwargs Additional arguments
49 @details Each capability e.g. may directly just call some command line program or execute building pythonic function
50 @return Capability call return value
52 if not kwargs[
'image_path']:
56 if not kwargs[
'destination_disk']:
61 target_id = kwargs.get(
'target_id',
None)
62 pooling_timeout = kwargs.get(
'polling_timeout', 60)
66 if kwargs[
'image_path']
and kwargs[
'destination_disk']:
67 image_path = os.path.normpath(kwargs[
'image_path'])
68 destination_disk = os.path.normpath(kwargs[
'destination_disk'])
72 mount_res, destination_disk = self.
check_mount_point_ready(destination_disk, target_id=target_id, timeout=pooling_timeout)
76 image_base_name = basename(image_path)
77 destination_path = join(destination_disk, image_base_name)
78 if capability ==
'shell':
79 if os.name ==
'nt': capability =
'copy'
80 elif os.name ==
'posix': capability =
'cp'
81 if capability ==
'cp' or capability ==
'copy' or capability ==
'copy':
82 copy_method = capability
83 cmd = [copy_method, image_path, destination_path]
84 if os.name ==
'posix':
86 if os.uname()[0] ==
'Linux':
87 result = result
and self.
run_command([
"sync",
"-f", destination_path])
96 """ Returns plugin available in this module