A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
#44: Harmonise environment variables with constant names
Daniel Quinn26c378135079
diff --git a/docs/changelog.rst b/docs/changelog.rstindex cdb720926..5b8029780 100644--- a/docs/changelog.rst+++ b/docs/changelog.rst@@ -3,6 +3,7 @@ Changelog* 0.1.1 (master)+ * `#44`_: Harmonise environment variable names with constant names.* `#60`_: Setup logging to actually use the Python native logging framework.* `#53`_: Fixed an annoying bug that caused ``.jpeg`` and ``.JPG`` imagesto be imported but made unavailable.@@ -68,6 +69,7 @@ Changelog.. _darkmatter: https://github.com/darkmatter.. _zedster: https://github.com/zedster+.. _#44: https://github.com/danielquinn/paperless/issues/44.. _#45: https://github.com/danielquinn/paperless/issues/45.. _#47: https://github.com/danielquinn/paperless/issues/47.. _#48: https://github.com/danielquinn/paperless/issues/48diff --git a/src/documents/forms.py b/src/documents/forms.pyindex 404be1763..8eb7b8381 100644--- a/src/documents/forms.py+++ b/src/documents/forms.py@@ -14,7 +14,7 @@ from .consumer import Consumerclass UploadForm(forms.Form):- SECRET = settings.UPLOAD_SHARED_SECRET+ SECRET = settings.SHARED_SECRETTYPE_LOOKUP = {"application/pdf": Document.TYPE_PDF,"image/png": Document.TYPE_PNG,diff --git a/src/documents/mail.py b/src/documents/mail.pyindex a5f5416cb..0bc3ce94f 100644--- a/src/documents/mail.py+++ b/src/documents/mail.py@@ -44,7 +44,7 @@ class Message(Loggable):and n attachments, and that we don't care about the message body."""- SECRET = settings.UPLOAD_SHARED_SECRET+ SECRET = settings.SHARED_SECRETdef __init__(self, data, group=None):"""@@ -175,7 +175,7 @@ class MailFetcher(Loggable):# Reset the grouping id for each fetchself.logging_group = uuid.uuid4()- self.log("info", "Checking mail")+ self.log("debug", "Checking mail")for message in self._get_messages():diff --git a/src/paperless/settings.py b/src/paperless/settings.pyindex 1f7bb6d0a..67f6c4a0c 100644--- a/src/paperless/settings.py+++ b/src/paperless/settings.py@@ -159,7 +159,7 @@ LOGGING = {}-# Paperless-specific stuffs+# Paperless-specific stuff# Change these paths if yours are different# ----------------------------------------------------------------------------@@ -173,19 +173,19 @@ OCR_THREADS = os.getenv("PAPERLESS_OCR_THREADS")# If this is true, any failed attempts to OCR a PDF will result in the PDF# being indexed anyway, with whatever we could get. If it's False, the file# will simply be left in the CONSUMPTION_DIR.-FORGIVING_OCR = True+FORGIVING_OCR = bool(os.getenv("PAPERLESS_FORGIVING_OCR", "YES").lower() in ("yes", "y", "1", "t", "true"))# GNUPG needs a home directory for some reasonGNUPG_HOME = os.getenv("HOME", "/tmp")-# Convert is part of the Imagemagick package-CONVERT_BINARY = "/usr/bin/convert"+# Convert is part of the ImageMagick package+CONVERT_BINARY = os.getenv("PAPERLESS_CONVERT_BINARY")# This will be created if it doesn't exist-SCRATCH_DIR = "/tmp/paperless"+SCRATCH_DIR = os.getenv("PAPERLESS_SCRATCH_DIR", "/tmp/paperless")# This is where Paperless will look for PDFs to index-CONSUMPTION_DIR = os.getenv("PAPERLESS_CONSUME")+CONSUMPTION_DIR = os.getenv("PAPERLESS_CONSUMPTION_DIR")# If you want to use IMAP mail consumption, populate this with useful values.# If you leave HOST set to None, we assume you're not going to use this@@ -211,4 +211,37 @@ PASSPHRASE = os.getenv("PAPERLESS_PASSPHRASE")# If you intend to use the "API" to push files into the consumer, you'll need# to provide a shared secret here. Leaving this as the default will disable# the API.-UPLOAD_SHARED_SECRET = os.getenv("PAPERLESS_SECRET", "")+SHARED_SECRET = os.getenv("PAPERLESS_SHARED_SECRET", "")++#+# TODO: Remove after 1.2+#+# This logic is here to address issue #44, wherein we were using inconsistent+# constant names vs. environment variables. If you're using Paperless for the+# first time, you can safely ignore everything from here on, so long as you're+# correctly defining the variables as per the documentation.+#+++def deprecated(before, after):+ print(+ "\n\n"+ "WARNING: {before} has been renamed to {after}.\n"+ "WARNING: Use of {before} will not work as of version 1.2."+ "\n\n".format(+ before=before,+ after=after+ )+ )++if not CONVERT_BINARY:+ deprecated("PAPERLESS_CONVERT", "PAPERLESS_CONVERT_BINARY")+ CONVERT_BINARY = os.getenv("PAPERLESS_CONVERT", "convert")++if not CONSUMPTION_DIR and os.getenv("PAPERLESS_CONSUME"):+ deprecated("PAPERLESS_CONSUME", "PAPERLESS_CONSUMPTION_DIR")+ CONSUMPTION_DIR = os.getenv("PAPERLESS_CONSUME")++if not SHARED_SECRET and os.getenv("PAPERLESS_SECRET"):+ deprecated("PAPERLESS_SECRET", "PAPERLESS_SHARED_SECRET")+ SHARED_SECRET = os.getenv("PAPERLESS_SECRET", "")diff --git a/src/paperless/urls.py b/src/paperless/urls.pyindex 55563c6c5..eb302638f 100644--- a/src/paperless/urls.py+++ b/src/paperless/urls.py@@ -47,5 +47,5 @@ urlpatterns = [] + static.static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)-if settings.UPLOAD_SHARED_SECRET:+if settings.SHARED_SECRET:urlpatterns.insert(0, url(r"^push$", PushView.as_view(), name="push"))diff --git a/src/paperless/version.py b/src/paperless/version.pyindex 8e2c2d9ea..d61abb655 100644--- a/src/paperless/version.py+++ b/src/paperless/version.py@@ -1 +1 @@-__version__ = (0, 1, 0)+__version__ = (0, 1, 1)