The parsemail and parsearchive scripts are currently the main way of loading content into Patchwork. However, running them requires modifying the PYTHONPATH environment variable, along with calls to configure Django before doing anything.
Django describes management commands as a good option for standalone scripts, which make it a good fit for these two scripts. Migrate these to management commands, moving the main bulk of the parsing code into a dedicated parsing module. As part of this, we fix some bugs and refactor some of the cruftier code. This sets us up nicely for adding an '/upload' endpoint at some point in the future, which could allow Patchwork to be deployed on PaaS systems. These systems don't have access to the underlying environment, meaning something like a Unix mailbox might not be available. An API may well be the only way to submit content in this area. Change since v5: - Rework unit tests to cover additional cases - Remove some unnecessary Django<1.8-handling code Stephen Finucane (2): parsemail: Convert to a management command parsearchive: Convert to a management command docs/development.md | 8 +- patchwork/bin/parsearchive.py | 106 ------------------------ patchwork/bin/parsemail.py | 114 -------------------------- patchwork/bin/parsemail.sh | 8 +- patchwork/management/commands/parsearchive.py | 106 ++++++++++++++++++++++++ patchwork/management/commands/parsemail.py | 81 ++++++++++++++++++ patchwork/parser.py | 12 +-- patchwork/settings/base.py | 60 ++++++++++++-- patchwork/tests/__init__.py | 23 ++++++ patchwork/tests/test_management.py | 112 +++++++++++++++++++++++++ patchwork/tests/test_parser.py | 4 +- patchwork/tests/utils.py | 2 +- 12 files changed, 396 insertions(+), 240 deletions(-) delete mode 100755 patchwork/bin/parsearchive.py delete mode 100755 patchwork/bin/parsemail.py create mode 100644 patchwork/management/commands/parsearchive.py create mode 100644 patchwork/management/commands/parsemail.py create mode 100644 patchwork/tests/test_management.py -- 2.7.4 _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork