Class: Webget
- Inherits:
-
QuartzPlugin
- Object
- QuartzPlugin
- Webget
- Defined in:
- lib/plugins/webget.rb
Constant Summary collapse
- @@version_major =
0
- @@version_minor =
0
- @@version_revision =
1
Instance Method Summary collapse
Methods inherited from QuartzPlugin
#get_version, #initialize, #payload, #run_result, #run_shell
Constructor Details
This class inherits a constructor from QuartzPlugin
Instance Method Details
#info ⇒ Object
10 11 12 |
# File 'lib/plugins/webget.rb', line 10 def info { :uid => "6b5f722d214f4d71a5be237d44094721", :name => "WebGet", :version => get_version } end |
#run(message) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/plugins/webget.rb', line 14 def run() @log.debug "Running with #{}" payload = payload() url = payload['url'] local = payload['local file'] @log.info "Webget from #{url} into #{local}" begin response = HTTParty.get(url) if response.code == 200 body = response.body file = File.new(local, "w") begin file.write(body) run_result(true, "Saved WebGet to local file") ensure file.close end else run_result(false, response.) end rescue => ex run_result(false, "Failed to webget due to #{ex}") end end |