[PATCH v4 0/2] Convert 'parse' scripts to management commands

Stephen Finucane stephenfinucane at hotmail.com
Sun Sep 4 10:12:36 AEST 2016


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 v3:
- Merge all but the last two patches
- Add support for Django 1.10
- Add unit tests

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 | 104 +++++++++++++++++++++++
 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            |  70 ++++++++++++++++
 patchwork/tests/test_parser.py                |   4 +-
 patchwork/tests/utils.py                      |   2 +-
 12 files changed, 352 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



More information about the Patchwork mailing list