mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
Re-adds the script arguments
This commit is contained in:
parent
f20254217f
commit
678bcb171a
@ -134,11 +134,19 @@ class Consumer(LoggingMixin):
|
|||||||
|
|
||||||
self.log("info", f"Executing pre-consume script {settings.PRE_CONSUME_SCRIPT}")
|
self.log("info", f"Executing pre-consume script {settings.PRE_CONSUME_SCRIPT}")
|
||||||
|
|
||||||
|
filepath_arg = os.path.normpath(self.path)
|
||||||
|
|
||||||
script_env = os.environ.copy()
|
script_env = os.environ.copy()
|
||||||
script_env["DOCUMENT_SOURCE_PATH"] = os.path.normpath(self.path)
|
script_env["DOCUMENT_SOURCE_PATH"] = filepath_arg
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Popen(settings.PRE_CONSUME_SCRIPT, env=script_env).wait()
|
Popen(
|
||||||
|
(
|
||||||
|
settings.PRE_CONSUME_SCRIPT,
|
||||||
|
filepath_arg,
|
||||||
|
),
|
||||||
|
env=script_env,
|
||||||
|
).wait()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._fail(
|
self._fail(
|
||||||
MESSAGE_PRE_CONSUME_SCRIPT_ERROR,
|
MESSAGE_PRE_CONSUME_SCRIPT_ERROR,
|
||||||
@ -170,24 +178,38 @@ class Consumer(LoggingMixin):
|
|||||||
script_env["DOCUMENT_ADDED"] = str(document.added)
|
script_env["DOCUMENT_ADDED"] = str(document.added)
|
||||||
script_env["DOCUMENT_FILE_NAME"] = document.get_public_filename()
|
script_env["DOCUMENT_FILE_NAME"] = document.get_public_filename()
|
||||||
script_env["DOCUMENT_SOURCE_PATH"] = os.path.normpath(document.source_path)
|
script_env["DOCUMENT_SOURCE_PATH"] = os.path.normpath(document.source_path)
|
||||||
script_env["DOCUMENT_ARCHIVE_PATH"] = os.path.normpath(str(document.archive_path))
|
script_env["DOCUMENT_ARCHIVE_PATH"] = os.path.normpath(
|
||||||
|
str(document.archive_path),
|
||||||
|
)
|
||||||
script_env["DOCUMENT_THUMBNAIL_PATH"] = os.path.normpath(
|
script_env["DOCUMENT_THUMBNAIL_PATH"] = os.path.normpath(
|
||||||
document.thumbnail_path
|
document.thumbnail_path,
|
||||||
)
|
)
|
||||||
script_env["DOCUMENT_DOWNLOAD_URL"] = reverse(
|
script_env["DOCUMENT_DOWNLOAD_URL"] = reverse(
|
||||||
"document-download", kwargs={"pk": document.pk}
|
"document-download",
|
||||||
|
kwargs={"pk": document.pk},
|
||||||
)
|
)
|
||||||
script_env["DOCUMENT_THUMBNAIL_URL"] = reverse(
|
script_env["DOCUMENT_THUMBNAIL_URL"] = reverse(
|
||||||
"document-thumb", kwargs={"pk": document.pk}
|
"document-thumb",
|
||||||
|
kwargs={"pk": document.pk},
|
||||||
)
|
)
|
||||||
script_env["DOCUMENT_CORRESPONDENT"] = str(document.correspondent)
|
script_env["DOCUMENT_CORRESPONDENT"] = str(document.correspondent)
|
||||||
script_env["DOCUMENT_TAGS"] = str(
|
script_env["DOCUMENT_TAGS"] = str(
|
||||||
",".join(document.tags.all().values_list("name", flat=True))
|
",".join(document.tags.all().values_list("name", flat=True)),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
Popen(
|
Popen(
|
||||||
settings.POST_CONSUME_SCRIPT,
|
(
|
||||||
|
settings.POST_CONSUME_SCRIPT,
|
||||||
|
str(document.pk),
|
||||||
|
document.get_public_filename(),
|
||||||
|
os.path.normpath(document.source_path),
|
||||||
|
os.path.normpath(document.thumbnail_path),
|
||||||
|
reverse("document-download", kwargs={"pk": document.pk}),
|
||||||
|
reverse("document-thumb", kwargs={"pk": document.pk}),
|
||||||
|
str(document.correspondent),
|
||||||
|
str(",".join(document.tags.all().values_list("name", flat=True))),
|
||||||
|
),
|
||||||
env=script_env,
|
env=script_env,
|
||||||
).wait()
|
).wait()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user