case cmd
when "SEND_REQ"
conn.puts "FILE_INFO,#{filename},#{size},#{checksum}"
+
+ full_size = size
+ old_progress = 0
# read file contents
# send via tcp/ip
File.open(src_file, "rb") do |io|
buf = io.read(size > 1024*1024 ? 1024*1024 : size)
conn.write( buf )
size -= buf.length
+
+ progress = ((( full_size - size ) * 10 ) / full_size )
+ if not progress.eql? old_progress then
+ @log.info "File transfer : #{progress}0 %"
+ old_progress = progress
+ end
end
end
raise RuntimeError, "Failed to create BuildCommClient instance.."
end
- @log.info "Send ready REQ.. [UPLOAD]"
+ @log.info "Send UPLOAD REQ.. [UPLOAD|#{dock}]"
result = client2.send("UPLOAD|#{dock}")
if not result then
raise RuntimeError, "Failed to send ready REQ.."
client = BuildCommClient.create(ip, port, @log)
if client.nil? then
- puts "Can't access server #{ip}:#{port}"
+ @log.error "Can't access server #{ip}:#{port}"
return nil
end
client.read_lines do |line|
if line.eql?("WAITFORUPLOAD") then
# upload
+ @log.info "Get WAITFORUPLOAD message"
thread = Thread.new do
begin
upload_request(ip, port, dock, transporter, binary_path_list)