#!/bin/sh
#
# Patchwork - automated patch tracking system
-# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
+# Copyright (C) 2017 Stephen Finucane <stephen@that.guru>
#
# This file is part of the Patchwork package.
#
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
BIN_DIR=$(dirname "$0")
+PATCHWORK_BASE=$(readlink -e "$BIN_DIR/../..")
-if [ $# -lt 1 ]; then
- echo "usage: $0 <dir> [options]" >&2
- exit 1
+if [ -z "$PW_PYTHON" ]; then
+ PW_PYTHON=python2
fi
-mail_dir="$1"
-
-echo "dir: $mail_dir"
-
-if [ ! -d "$mail_dir" ]; then
- echo "$mail_dir should be a directory"? >&2
- exit 1
+if [ -z "$DJANGO_SETTINGS_MODULE" ]; then
+ DJANGO_SETTINGS_MODULE=patchwork.settings.production
fi
-shift
-
-find "$mail_dir" -maxdepth 1 |
-while read -r line; do
- echo "$line"
- "$BIN_DIR/parsemail.sh" "$@" < "$line"
-done
+PYTHONPATH="${PATCHWORK_BASE}:${PATCHWORK_BASE}/lib/python:$PYTHONPATH" \
+ DJANGO_SETTINGS_MODULE="$DJANGO_SETTINGS_MODULE" \
+ "$PW_PYTHON" "$PATCHWORK_BASE/manage.py" parsearchive "$@"
self.stdout.write('Invalid path: %s' % path)
sys.exit(1)
- mbox = mailbox.mbox(path)
+ # assume if <infile> is a directory, then we're passing a maildir
+ if os.path.isfile(path):
+ mbox = mailbox.mbox(path)
+ else:
+ mbox = mailbox.Maildir(path)
+
count = len(mbox)
logger.info('Parsing %d mails', count)