def archive_docket_xml_locally(court, casenum, directory = "archived_dockets"): docket_url = IACommon.get_docketxml_url(court, casenum) if os.system("wget --quiet --directory-prefix=%s %s" % (directory, docket_url)) != 0: print "Could not archive this docket, exiting without trying to delete..." exit() print " saved docket %s.%s for analysis in %s directory" % (court, casenum, directory)
def get_docket_string(court, casenum): docketurl = IACommon.get_docketxml_url(court, casenum) request = urllib2.Request(docketurl) try: response = opener.open(request) except urllib2.HTTPError, e: # HTTP Error if e.code == 404: bits = e.read() # IA returns different 404 pages if the bucket exists or not # This might be a brittle way to check the difference, but don't think there's a better way if (bits.find(NO_BUCKET_HTML_MESSAGE) > 0): return None, FETCH_NO_BUCKET # Otherwise, assume the bucket exists return None, FETCH_NO_FILE else: logging.info("get_docket_string: unknown fetch code %d" % e.code) return None, FETCH_UNKNOWN
def get_docket_string(court, casenum): docketurl = IACommon.get_docketxml_url(court, casenum) request = urllib2.Request(docketurl) try: response = opener.open(request) except urllib2.HTTPError, e: # HTTP Error if e.code == 404: bits = e.read() # IA returns different 404 pages if the bucket exists or not # This might be a brittle way to check the difference, but don't think there's a better way if(bits.find(NO_BUCKET_HTML_MESSAGE) > 0): return None, FETCH_NO_BUCKET # Otherwise, assume the bucket exists return None, FETCH_NO_FILE else: logging.info("get_docket_string: unknown fetch code %d" % e.code) return None, FETCH_UNKNOWN