Removed parameter, added documentation

This commit is contained in:
André Heuer
2023-08-21 13:33:34 +02:00
committed by shamoon
parent 8f8a99a645
commit 88ee3bdb6d
3 changed files with 36 additions and 35 deletions

View File

@@ -186,7 +186,7 @@ class Consumer(LoggingMixin):
f"Not consuming {self.filename}: Given ASN already exists!",
)
def run_pre_consume_script(self, task_id):
def run_pre_consume_script(self):
"""
If one is configured and exists, run the pre-consume script and
handle its output and/or errors
@@ -209,7 +209,7 @@ class Consumer(LoggingMixin):
script_env = os.environ.copy()
script_env["DOCUMENT_SOURCE_PATH"] = original_file_path
script_env["DOCUMENT_WORKING_PATH"] = working_file_path
script_env["TASK_ID"] = task_id
script_env["TASK_ID"] = self.task_id or ""
try:
completed_proc = run(
@@ -234,7 +234,7 @@ class Consumer(LoggingMixin):
exception=e,
)
def run_post_consume_script(self, document: Document, task_id):
def run_post_consume_script(self, document: Document):
"""
If one is configured and exists, run the pre-consume script and
handle its output and/or errors
@@ -280,7 +280,7 @@ class Consumer(LoggingMixin):
",".join(document.tags.all().values_list("name", flat=True)),
)
script_env["DOCUMENT_ORIGINAL_FILENAME"] = str(document.original_filename)
script_env["TASK_ID"] = task_id
script_env["TASK_ID"] = self.task_id or ""
try:
completed_proc = run(
@@ -390,7 +390,7 @@ class Consumer(LoggingMixin):
logging_group=self.logging_group,
)
self.run_pre_consume_script(task_id=self.task_id)
self.run_pre_consume_script()
def progress_callback(current_progress, max_progress): # pragma: no cover
# recalculate progress to be within 20 and 80
@@ -555,7 +555,7 @@ class Consumer(LoggingMixin):
document_parser.cleanup()
tempdir.cleanup()
self.run_post_consume_script(document, task_id=self.task_id)
self.run_post_consume_script(document)
self.log.info(f"Document {document} consumption finished")