From: Brandon King Date: Sat, 17 Nov 2007 02:41:33 +0000 (+0000) Subject: [project @ retrieve_eland_config.py catches two new errors] X-Git-Tag: 0.1.0~61 X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=127be0264ec4027c15ceca640fe28b94438dbfa4 [project @ retrieve_eland_config.py catches two new errors] * Handles 404 - Not found (throws exception) * Handles Flowcell not in DB (throws exception) --- diff --git a/bin/retrieve_eland_config.py b/bin/retrieve_eland_config.py index 3c8825b..228aec9 100644 --- a/bin/retrieve_eland_config.py +++ b/bin/retrieve_eland_config.py @@ -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: