[project @ Updated to give more user friendly error:]
authorBrandon King <kingb@caltech.edu>
Sat, 10 Nov 2007 01:20:19 +0000 (01:20 +0000)
committerBrandon King <kingb@caltech.edu>
Sat, 10 Nov 2007 01:20:19 +0000 (01:20 +0000)
 * Gives a more user friendly error when connection is refused.
 * FIXME: Should include other errors as well, such as host lookup errors.

bin/retrieve_eland_config.py

index cfd77f112e86ed59e4322950f17db2ea55f473fa..7cb116bb66d7be5f5d104f1b774d9b7000e6db73 100644 (file)
@@ -92,9 +92,11 @@ def getCombinedOptions():
     if conf_parser.has_option('server_info', 'base_host_url'):
       options.url = conf_parser.get('server_info', 'base_host_url')
   
-  print 'URL:', options.url
-  print 'OUT:', options.output_filepath
-  print ' FC:', options.flowcell
+  print 'USING OPTIONS:'
+  print ' URL:', options.url
+  print ' OUT:', options.output_filepath
+  print '  FC:', options.flowcell
+  print ''
   
   return options
 
@@ -107,7 +109,16 @@ def saveConfigFile(flowcell, base_host_url, output_filepath):
   url = base_host_url + '/elandifier/config/%s/' % (flowcell)
   
   f = open(output_filepath, 'w')
-  web = urllib.urlopen(url)
+  try:
+    web = urllib.urlopen(url)
+  except IOError, msg:
+    if str(msg).find("Connection refused") >= 0:
+      print 'Error: Could not connect to: %s' % (url)
+      f.close()
+      sys.exit(1)
+    else:
+      raise IOError, msg
+    
   f.write(web.read())
   web.close()
   f.close()