Exemplo n.º 1
0
def consume_file(path,
                 override_filename=None,
                 override_title=None,
                 override_correspondent_id=None,
                 override_document_type_id=None,
                 override_tag_ids=None,
                 task_id=None):

    document = Consumer().try_consume_file(
        path,
        override_filename=override_filename,
        override_title=override_title,
        override_correspondent_id=override_correspondent_id,
        override_document_type_id=override_document_type_id,
        override_tag_ids=override_tag_ids,
        task_id=task_id
    )

    if document:
        return "Success. New document id {} created".format(
            document.pk
        )
    else:
        raise ConsumerError("Unknown error: Returned document was null, but "
                            "no error message was given.")
Exemplo n.º 2
0
 def bogus_task(self, func, filename, **kwargs):
     eq = filecmp.cmp(filename, self.sample_file, shallow=False)
     if not eq:
         print("Consumed an INVALID file.")
         raise ConsumerError("Incomplete File READ FAILED")
     else:
         print("Consumed a perfectly valid file.")