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
272
273
274
275
276
277
278
279
|
# File 'lib/oddb2xml/downloader.rb', line 237
def download
begin
filename = "refdata_#{@type}.xml"
@file2save = File.join(Downloads, "refdata_#{@type}.xml")
soap = %(<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://refdatabase.refdata.ch/Article_in" xmlns:ns2="http://refdatabase.refdata.ch/">
<SOAP-ENV:Body>
<ns2:DownloadArticleInput>
<ns1:ATYPE>#{@type.upcase}</ns1:ATYPE>
</ns2:DownloadArticleInput>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
</ns1:ATYPE></ns2:DownloadArticleInput></SOAP-ENV:Body>
)
report_download(@url, @file2save)
return IO.read(@file2save) if Oddb2xml.skip_download? and File.exists?(@file2save)
FileUtils.rm_f(@file2save, :verbose => false)
response = @client.call(:download, :xml => soap)
if response.success?
if xml = response.to_xml
xml = File.read(File.join(Oddb2xml::SpecData, File.basename(@file2save))) if defined?(RSpec)
response = nil FileUtils.makedirs(Downloads)
File.open(@file2save, 'w+') { |file| file.write xml }
if @options[:artikelstamm]
cmd = "xmllint --format --output #{@file2save} #{@file2save}"
Oddb2xml.log(cmd)
system(cmd)
end
else
raise StandardError
end
else
raise Timeout::Error
end
rescue HTTPI::SSLError
exit rescue Timeout::Error, Errno::ETIMEDOUT
retrievable? ? retry : raise
end
xml
end
|