class SiSU_Remote::Get
Public Class Methods
new(opt,get_s)
click to toggle source
# File lib/sisu/remote.rb, line 133 def initialize(opt,get_s) @opt,@get_s=opt,get_s @msg,@msgs='',nil @tell=lambda { SiSU_Screen::Ansi.new(@opt.act[:color_state][:set], @msg, "#{@msgs.inspect if @msgs}") } end
Public Instance Methods
fns()
click to toggle source
# File lib/sisu/remote.rb, line 142 def fns begin require 'open-uri' require 'pp' rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). error('open-uri or pp NOT FOUND (LoadError)') end require_relative 'ao_composite' # ao_composite.rb @rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ threads=[] for requested_page in @get_s re_fnb=/((?:https?|file):\/\/[^\/ ]+?\/[^\/ ]+?)\/\S+?\/([^\/]+?)\.ss(t)/ #revisit and remove DO threads << Thread.new(requested_page) do |url| open(url) do |f| raise "#{url} not found" unless f base_uri,fnb=re_fnb.match(url)[1..2] if re_fnb imagedir=base_uri + '/_sisu/image' #check on downloaded_file=File.new("#{fnb}.-sst",'w+') image_download_url=SiSU_Assemble::RemoteImage.new.image(imagedir) images=[] f.collect.each do |r| # work area unless r =~/^%+\s/ if r !~/^%+\s/ \ and r =~@rgx_image images << r.scan(@rgx_image).uniq end end downloaded_file << r end if images \ and images.length > 1 images=images.flatten.uniq images.delete_if {|x| x =~/https?:\/\// } images=images.sort @msg,@msgs='downloading images:', [ images.join(',') ] @tell.call.warn unless @opt.act[:quiet][:set]==:on image_info=image_download_url + images SiSU_Assemble::RemoteImage.new.download_images(image_info) #SiSU_Assemble::RemoteImage.new.download_images(image_download_url,images) @msg,@msgs='downloading done',nil @tell.call.warn unless @opt.act[:quiet][:set]==:on end downloaded_file.close end end end threads.each {|thr| thr.join} if threads #and threads.length > 0 end
sisupod()
click to toggle source
# File lib/sisu/remote.rb, line 191 def sisupod get_p=@get_s if get_p.length > 0 #% remote sisupod begin require 'net/http' rescue LoadError SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). error('net/http NOT FOUND (LoadError)') end for requested_pod in get_p pod_info=RemoteDownload.new(requested_pod) Net::HTTP.start(pod_info.pod.site) do |http| resp=http.get("#{pod_info.pod.path}/#{pod_info.pod.name_source}") open(pod_info.pod.name,'wb') do |file| file.write(resp.body) end end end end end