Class: RbEAI::GetFtpLogic

Inherits:
Object
  • Object
show all
Defined in:
lib/rbeai/GetLogic.rb

Instance Method Summary collapse

Constructor Details

#initialize(protNode, task) ⇒ GetFtpLogic

Returns a new instance of GetFtpLogic.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rbeai/GetLogic.rb', line 53

def initialize(protNode, task)
  @task = task
  location  = XPath.first(protNode, "./location")
     = XPath.first(protNode, "./account")
  @address  = location.attributes["address"]
  @port     = location.attributes["port"]
  @folder   = location.attributes["folder"]
  @name     = .attributes["name"]
  @pwd      = .attributes["pwd"]    
  @pattern  = task.pattern
end

Instance Method Details

#getFilesObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rbeai/GetLogic.rb', line 65

def getFiles()
begin
	filesaux = []
	Net::FTP.open(@address) do |ftp|
		ftp.(@name, @pwd)
		files = ftp.chdir(@folder)
		files = ftp.ls("#{@pattern}")
		re = Regexp.new("#{@pattern}")
		rio("tmp/#{@task.wflow.instid}/#{@task.name}").mkdir  
		files.each do |file|
			mr = re.match(file)
			puts mr
			remotefilename = mr[0]
			localfilename = "tmp/#{@task.wflow.instid}/#{@task.name}/#{remotefilename}"
			puts localfilename
			ftp.gettextfile(remotefilename, localfilename)
			filesaux << localfilename
		end
	end
  return filesaux
      rescue Exception 
        puts $!
      end      
end