[project @ Updated eland_config app to generate config file from fctracker app.]
[htsworkflow.git] / bin / retrieve_eland_config.py
index cfd77f112e86ed59e4322950f17db2ea55f473fa..3c8825ba7aa7e86c9775cd929fd16693d2356d5a 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
 
@@ -104,13 +106,27 @@ def saveConfigFile(flowcell, base_host_url, output_filepath):
   retrieves the flowcell eland config file, give the base_host_url
   (i.e. http://sub.domain.edu:port)
   """
-  url = base_host_url + '/elandifier/config/%s/' % (flowcell)
+  url = base_host_url + '/eland_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: Connection refused for: %s' % (url)
+      f.close()
+      sys.exit(1)
+    elif str(msg).find("Name or service not known") >= 0:
+      print 'Error: Invalid domain or ip address for: %s' % (url)
+      f.close()
+      sys.exit(2)
+    else:
+      raise IOError, msg
+    
   f.write(web.read())
   web.close()
   f.close()
+  print 'Wrote config file to %s' % (output_filepath)
 
 if __name__ == '__main__':
   #Display help if no args are presented