brand2csv 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.2.4 06.06.2013
2
+
3
+ * Rescue another exception
4
+
1
5
  === 0.2.3 06.06.2013
2
6
 
3
7
  * Added option --swiss_only
data/lib/brand2csv.rb CHANGED
@@ -341,8 +341,23 @@ module Brand2csv
341
341
  url = "#{Sr300}?language=de&section=tm&id=#{nummer}"
342
342
  pp "#{Time.now.strftime("%H:%M:%S")}: Opening #{filename}" if $VERBOSE
343
343
  $stdout.flush
344
- content = @agent.get_file url
345
- body = @agent.page.body
344
+ nrRetries = 0
345
+ begin
346
+ content = @agent.get_file url
347
+ body = @agent.page.body
348
+ rescue 'getaddrinfo: Name or service not known', Exception => e
349
+ nrRetries += 1
350
+ puts e.backtrace
351
+ if nrRetries <= 3
352
+ puts "get_file did not work reinit session and retry for #{nr}. nrRetries #{nrRetries}/3. e #{e}"
353
+ sleep 60 # Sleep a minute to let network recover
354
+ init_swissreg
355
+ retry
356
+ else
357
+ puts "get_file did not work reinit session raise Interrupt"
358
+ raise Interrupt
359
+ end
360
+ end
346
361
  body.force_encoding('utf-8') unless /^1\.8/.match(RUBY_VERSION)
347
362
  doc = Nokogiri::Slop(body)
348
363
  writeResponse(filename)
@@ -517,14 +532,16 @@ module Brand2csv
517
532
  nrRetries = 0
518
533
  begin
519
534
  fetchDetails(nr)
520
- rescue Exception => e
535
+ rescue SocketError, Exception => e
521
536
  nrRetries += 1
522
537
  puts e.backtrace
523
- puts "fetchDetails did not work reinit session and retry for #{nr}. nrRetries #{nrRetries}/3. e #{e}"
524
538
  if nrRetries <= 3
539
+ puts "fetchDetails did not work reinit session and retry for #{nr}. nrRetries #{nrRetries}/3. e #{e}"
540
+ sleep 60 # Sleep a minute to let network recover
525
541
  init_swissreg
526
542
  retry
527
543
  else
544
+ puts "fetchDetails did not work reinit session raise Interrupt"
528
545
  raise Interrupt
529
546
  end
530
547
  end
@@ -1,3 +1,3 @@
1
1
  module Brand2csv
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brand2csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize