Module: MobyBehaviour::QT::FileTransfer
- Includes:
- Behaviour
- Defined in:
- lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb
Overview
description
This module contains implementation to control sut file transfers
behaviour
FileTransfer
requires
testability-driver-qt-sut-plugin
input_type
*
sut_type
qt
sut_version
*
objects
sut
Instance Method Summary collapse
-
#copy_from_sut(arguments) ⇒ Object
info.
-
#copy_to_sut(arguments) ⇒ Object
info.
-
#delete_from_sut(arguments) ⇒ Object
info.
-
#list_files_from_sut(arguments) ⇒ Object
Info.
Methods included from Behaviour
Instance Method Details
#copy_from_sut(arguments) ⇒ Object
info
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb', line 141 def copy_from_sut( arguments ) arguments.check_type Hash, "wrong argument type $1 for #{ __method__.to_s } method (expected $2)" device_path=arguments[ :from ].gsub('\\','/') if arguments.include?( :from ) if arguments[ :file ]!=nil file=arguments[ :file ].gsub('\\','/') else file='*.*' end if arguments[:to]!=nil tmp_path=arguments[:to].gsub('\\','/') if File::directory?(tmp_path)==false FileUtils.mkdir_p tmp_path end else tmp_path=Dir.getwd end if device_path!=nil list_of_files = list_files_from_sut(:from=>device_path,:file=>file) list_of_files.each do |name| end_index=(name.index File.basename(name))-1 start_index=(name.index device_path)+device_path.length file_folder=name[start_index..end_index] receive_file_from_device(name,File.join("#{tmp_path}#{file_folder}",File.basename(name))) end return list_of_files else arguments.require_key :file, 'Argument $1 not found' receive_file_from_device(file,File.join(arguments[ :to ],File.basename(file))) end end |
#copy_to_sut(arguments) ⇒ Object
info
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb', line 206 def copy_to_sut(arguments) arguments.check_type Hash, "wrong argument type $1 for #{ __method__.to_s } method (expected $2)" arguments.require_key :to, 'Argument $1 not found' begin local_dir = Dir.new( arguments[ :from ] ) if arguments.include?( :from ) rescue Errno::ENOENT raise RuntimeError, "The source folder does not exist. Details:\n#{ $!.inspect }" end if arguments[ :file ]!=nil file=arguments[ :file ].gsub('\\','/') else file='*.*' file='*.*' end transfered_files=Array.new #ensure that the base dir exist fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}"}) if arguments.include?( :file )==false arguments.require_key :from, 'Argument $1 not found' local_dir.entries.each do | local_file_or_subdir | if !File.directory?( File.join( arguments[ :from ], local_file_or_subdir ) ) send_file_to_device( File.join( arguments[ :from ], local_file_or_subdir ), File.join( arguments[ :to ], File.basename(local_file_or_subdir)) ) transfered_files << "#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}" elsif local_file_or_subdir != "." && local_file_or_subdir != ".." fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}/#{local_file_or_subdir}"}) transfered_files << copy_to_sut(:from=>"#{arguments[ :from ]}/#{local_file_or_subdir}", :to=>"#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}") end end elsif arguments.include?( :file ) && arguments.include?( :from ) local_dir.entries.each do | local_file_or_subdir | if !File.directory?( File.join( arguments[ :from ], local_file_or_subdir ) ) send_file_to_device( File.join( arguments[ :from ],local_file_or_subdir ), File.join( arguments[ :to ], File.basename(local_file_or_subdir)) ) if local_file_or_subdir.include?(file) transfered_files << "#{arguments[ :to ]}/#{File.basename(local_file_or_subdir)}" elsif local_file_or_subdir != "." && local_file_or_subdir != ".." fixture("file","mk_dir",{:file_name=>"#{arguments[ :to ]}/#{local_file_or_subdir}"}) transfered_files << copy_to_sut(:file => arguments( :file ), :from=>"#{arguments[ :from ]}/#{local_file_or_subdir}", :to=>"#{arguments[ :to ]}/#{local_file_or_subdir}") end end else arguments.require_key :file, 'Argument $1 not found' fixture("file","mk_dir",{:file_name=>{:file_name=>arguments[ :to ]}}) send_file_to_device( file, File.join(arguments[ :to ],File.basename(file)) ) transfered_files << "#{arguments[ :to ]}/#{File.basename(file)}" end return transfered_files end |
#delete_from_sut(arguments) ⇒ Object
info
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb', line 73 def delete_from_sut( arguments ) arguments.check_type Hash, "wrong argument type $1 for #{ __method__.to_s } method (expected $2)" if arguments.include?( :file ) file=arguments[ :file ].gsub('\\','/') device_path=arguments[ :from ].gsub('\\','/') if arguments.include?(:from) if device_path!=nil ret_list_of_files = [] list_of_files = list_files_from_sut(:from=>device_path,:file=>file) list_of_files.each do |name| if fixture("file", "delete_file", {:file_name => name}) == "OK" ret_list_of_files << name end end return ret_list_of_files else if fixture("file", "delete_file", {:file_name => file}) == "OK" return File.basename(file) end return end elsif arguments.include?(:dir) if fixture("file", "rm_dir", {:file_name => arguments[:dir]}) == "OK" return arguments[:dir] end return else arguments.require_key :file, 'Argument $1 not found' arguments.require_key :dir, 'Argument $1 not found' end end |
#list_files_from_sut(arguments) ⇒ Object
Info
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/behaviours/file_transfer.rb', line 295 def list_files_from_sut( arguments ) arguments.check_type Hash, "wrong argument type $1 for #{ __method__.to_s } method (expected $2)" arguments.require_key :from, 'Argument $1 not found' device_path=arguments[ :from ].gsub('\\','/') if arguments[ :file ]!=nil file=arguments[ :file ].gsub('\\','/') else file='*.*' file='*.*' end list_of_files = fixture("file", "list_files", {:file_name => file, :file_path => device_path}).split(';') return list_of_files end |