X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=blobdiff_plain;f=scripts%2Fmark_archived_data;h=62eca10304a0b52afa4322ca7d679dcef6041d42;hp=bd83b3bc9469e5984acf8a5b09bd1ba85de0a999;hb=e45e32854d72c32cfe1fc6e723b86ca189603d31;hpb=99b865c3c9fd6922d1d0bd6fd0f14d597d7e171f diff --git a/scripts/mark_archived_data b/scripts/mark_archived_data index bd83b3b..62eca10 100755 --- a/scripts/mark_archived_data +++ b/scripts/mark_archived_data @@ -11,6 +11,8 @@ from optparse import OptionParser import sys import urllib +import urllib2 + def construct_parser(): @@ -32,16 +34,19 @@ def update_db(flowcell, serial, debug=False): """ Creates link between flowcell and storage device over http """ - www = urllib.urlopen(settings.LINK_FLOWCELL_STORAGE_DEVICE_URL+'%s/%s/' % (flowcell, serial)) - httpcode = www.getcode() - if httpcode != 200: - print 'ERROR - HTTP OUTPUT (Return Code: %s); use -v/--verbose for more details.' % (httpcode) + url = settings.LINK_FLOWCELL_STORAGE_DEVICE_URL+'%s/%s/' % (flowcell, serial) + + req = urllib2.Request(url) + try: + response = urllib2.urlopen(req) + except urllib2.URLError, e: + print 'ERROR - HTTP OUTPUT (Return Code: %s); use -v/--verbose for more details.' % (e.code) if debug: - print www.read() - sys.exit(httpcode) + print e.read() + sys.exit(e.code) print "DB Update of %s & %s succeeded" % (flowcell, serial) - print www.read() + print response.read() def process_args(parser):