[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Debian JP master SVN www commits (rev.1044)



=======================================================
Repository: /org/svn.debian.or.jp/repos
  Revision: 1044
  Commiter: kmuto
      Date: 2010-06-02 22:34:17 +0900 (水, 02  6月 2010)
=======================================================
Log:

rescue exception

=======================================================
Changed:

U   cdn/trunk/gae-surrogates.rb

Modified: cdn/trunk/gae-surrogates.rb
===================================================================
--- cdn/trunk/gae-surrogates.rb	2010-06-02 10:31:45 UTC (rev 1043)
+++ cdn/trunk/gae-surrogates.rb	2010-06-02 13:34:17 UTC (rev 1044)
@@ -25,7 +25,7 @@
 #
 # Then, this script makes './addr'.
 
-#require 'rubygems'
+require 'rubygems'
 require 'json'
 require 'open-uri'
 
@@ -40,28 +40,33 @@
   p $!
   
 end
-pj = JSON.parse(json)
 
-addr = Hash.new
+begin
+  pj = JSON.parse(json)
 
-pj.each do |hs|
-  country = hs['country']
-  hostname = hs['hostname']
-  if addr[country]
-  else
-    addr[country] = Hash.new
+  addr = Hash.new
+
+  pj.each do |hs|
+    country = hs['country']
+    hostname = hs['hostname']
+    if addr[country]
+    else
+      addr[country] = Hash.new
+    end
+    
+    if addr[country][hostname]
+    else
+      addr[country][hostname] = Array.new
+    end
+    addr[country][hostname].push([hs['ip'].split('.').map{|x| x.to_i}, hs['preference']])
   end
-  
-  if addr[country][hostname]
-  else
-    addr[country][hostname] = Array.new
-  end
-  addr[country][hostname].push([hs['ip'].split('.').map{|x| x.to_i}, hs['preference']])
-end
 
-addrfile = File.open("addr", 'w')
-addrfile.puts "##" + Time.now.to_s
-addrfile.puts "##" + ARGV[0] + "\n\n"
-addrfile.puts '$addr_db = ' + addr.inspect
-addrfile.close
+  addrfile = File.open("addr", 'w')
+  addrfile.puts "##" + Time.now.to_s
+  addrfile.puts "##" + ARGV[0] + "\n\n"
+  addrfile.puts '$addr_db = ' + addr.inspect
+  addrfile.close
 
+rescue => ex
+  p ex.class
+end