def add_document_to_blacklist(document): BLACKLIST_PATH = "../blacklist" f = open(BLACKLIST_PATH, "a") f.write(IACommon.get_pdfname(document.court, document.casenum, document.docnum, document.subdocnum) + "\n") f.close() print " added document to %s, you may want to add a comment in that file" % BLACKLIST_PATH
def add_document_to_blacklist(document): BLACKLIST_PATH = "../blacklist" f = open(BLACKLIST_PATH, "a") f.write( IACommon.get_pdfname(document.court, document.casenum, document.docnum, document.subdocnum) + "\n") f.close() print " added document to %s, you may want to add a comment in that file" % BLACKLIST_PATH
def put_file(filebits, court, casenum, docnum, subdocnum, metadict={}): """ PUT the file into a new Internet Archive bucket. """ request = IACommon.make_pdf_request(filebits, court, casenum, docnum, subdocnum, metadict) # If this file is already scheduled, drop this. # TK: what we want? filename = IACommon.get_pdfname(court, casenum, docnum, subdocnum) query = PickledPut.objects.filter(filename=filename) if query: logging.info("put_file: same file already pickled. %s" % filename) return "IA PUT failed: the same file is already in the pickle bucket." # Add a PickledPut DB entry to schedule the PUT, not yet ready ppentry = PickledPut(filename=filename) # Fix a race case? try: ppentry.save() except IntegrityError: logging.info("put_file: same file already pickled. %s" % filename) return "IA PUT failed: the same file is already in the pickle bucket." # Pickle the request object into the jar pickle_success, message = pickle_object(request, filename) if pickle_success: # PickledPut now ready for processing. ppentry.ready = 1 ppentry.save() logging.info("put_file: ready. %s" % filename) else: # Could not pickle object, so remove from DB logging.warning("put_file: could not pickle PDF. %s" % filename) ppentry.delete() return message