[project @ retrieve_eland_config.py catches two new errors]
authorBrandon King <kingb@caltech.edu>
Sat, 17 Nov 2007 02:41:33 +0000 (02:41 +0000)
committerBrandon King <kingb@caltech.edu>
Sat, 17 Nov 2007 02:41:33 +0000 (02:41 +0000)
 * Handles 404 - Not found (throws exception)
 * Handles Flowcell not in DB (throws exception)

bin/retrieve_eland_config.py

index 3c8825ba7aa7e86c9775cd929fd16693d2356d5a..228aec9a7fcc9252f9e2a28332b4ec306b7fc136 100644 (file)
@@ -10,6 +10,11 @@ import urllib
 CONFIG_SYSTEM = '/etc/ga_frontend/ga_frontend.conf'
 CONFIG_USER = os.path.expanduser('~/.ga_frontend.conf')
 
+
+class FlowCellNotFound(Exception): pass
+class WebError404(Exception): pass
+
+
 class PreformattedDescriptionFormatter(IndentedHelpFormatter):
   
   #def format_description(self, description):
@@ -122,12 +127,24 @@ def saveConfigFile(flowcell, base_host_url, output_filepath):
       sys.exit(2)
     else:
       raise IOError, msg
-    
-  f.write(web.read())
+
+  data = web.read()
+
+  if data.find('Hmm, config file for') >= 0:
+    msg = "Flowcell (%s) not found in DB; full url(%s)" % (flowcell, url)
+    raise FlowCellNotFound, msg
+
+  if data.find('404 - Not Found') >= 0:
+    msg = "404 - Not Found: Flowcell (%s); base_host_url (%s);\n full url(%s)\n " \
+          "Did you get right port #?" % (flowcell, base_host_url, url)
+    raise FlowCellNotFound, msg
+  
+  f.write(data)
   web.close()
   f.close()
   print 'Wrote config file to %s' % (output_filepath)
 
+
 if __name__ == '__main__':
   #Display help if no args are presented
   if len(sys.argv) == 1: