aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG7
-rw-r--r--Makefile2
-rw-r--r--README61
-rw-r--r--TODO2
-rwxr-xr-xarchivemail.py12
-rwxr-xr-xsetup.py8
-rwxr-xr-xtest_archivemail.py30
7 files changed, 81 insertions, 41 deletions
diff --git a/CHANGELOG b/CHANGELOG
index fcaec6b..2747fd9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,11 @@
+Version 0.4.3 - 26 April 2002
+ * Fixed a couple of bugs where I was using python version 2.2 syntax that
+ was giving errors in python v2.0 and v2.1.
+ * Changed the python requirements for the test script from python version
+ 2.0 to version 2.1. This is because the unittest module is only available
+ in version 2.1 and above.
+
Version 0.4.2 - 24 April 2002
* Added the ability to archive messages older than a given absolute date
with the new option '--date'.
diff --git a/Makefile b/Makefile
index f7b0a43..af24e19 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-VERSION=0.4.2
+VERSION=0.4.3
VERSION_TAG=v$(subst .,_,$(VERSION))
TARFILE=archivemail-$(VERSION).tar.gz
diff --git a/README b/README
index 8506f62..5c70188 100644
--- a/README
+++ b/README
@@ -3,13 +3,7 @@
archivemail - archive and compress old mail in your mailbox
-----------------------------------------------------------
-INSTALLATION:
-
-To install archivemail, run:
- python setup.py install
-
-
-USE:
+OVERVIEW:
archivemail is a tool written in python(1) for archiving and compressing old
email in mailboxes.
@@ -25,19 +19,54 @@ just the most recent messages.
'archivemail' can save a lot of disk space and will significantly reduce
overhead on your mail reader. The number of days before mail is considered
-'old' is up to you, but the default is 180 days.
+'old' is up to you, but the default is 180 days. You can also archive messages
+by an absolute date or only archive unread messages.
-For more detailed information, look at the archivemail man page.
-'archivemail' currently works on mbox, maildir and MH format mailboxes
-and requires python v2.0 or greater. It also supports deleting old mail
-instead of archiving it with the '--delete' option.
+REQUIREMENTS:
+
+archivemail requires python version 2.0 or later, with the optional 'zlib'
+module, although the zlib module comes with most python installations. If you
+are compiling your own version of python < version 2.2, make sure you
+uncomment the 'zlib' moduile in Modules/Setup in the python source directory.
+
+You can check to see if you version of python has the 'zlib' module by
+trying this:
+
+ flare:~$ python
+ Python 2.1 (#1, Apr 26 2002, 11:22:45)
+ [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
+ Type "copyright", "credits" or "license" for more information.
+ >>> import zlib
+ >>>
+
+If you get an ImportError, then the zlib python module has not been installed.
+Try upgrading your python distribution.
+
+Python is available from http://www.python.org/
-The best way to run archivemail is from cron. Giving the '-q' option to
-archivemail will make it quiet, only printing messages if something went
-wrong. Check out the 'examples' directory for an example shell script to
-be run from cron.
+If you want to run the bundled test script, you will need python version 2.1
+or later, because we use the PyUnit 'unittest' module. Sorry.
+
+
+INSTALLATION:
+
+To install archivemail, run:
+ python setup.py install
+
+
+USE:
+
+For more detailed information, look at the archivemail man page.
+
+The best way to run archivemail is from cron, giving the '-q' option to
+archivemail to make it quiet, only printing messages if something went wrong.
+Check out the 'examples' directory for an example shell script to be run from
+cron.
The archivemail website is at: http://archivemail.sourceforge.net/
+If you have any feedback or bug reports about archivemail, you are very
+welcome to email me.
+
-- Paul Rodger <paul@paulrodger.com>
diff --git a/TODO b/TODO
index 0dc95a5..25112ad 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,5 @@
-Goals for next minor release (0.4.3):
+Goals for next minor release (0.4.4):
-------------------------------------
* Think about the best way to specify the names of archives created with
possibly an --archive-name option.
diff --git a/archivemail.py b/archivemail.py
index 148d7a5..7aa2424 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -22,18 +22,18 @@ Website: http://archivemail.sourceforge.net/
"""
# global administrivia
-__version__ = "archivemail v0.4.2"
+__version__ = "archivemail v0.4.3"
__cvs_id__ = "$Id$"
__copyright__ = """Copyright (C) 2002 Paul Rodger <paul@paulrodger.com>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."""
-
import sys
def check_python_version():
"""Abort if we are running on python < v2.0"""
- too_old_error = "This program requires python v2.0 or greater."
+ too_old_error = """This program requires python v2.0 or greater.
+Your version of python is: %s""" % sys.version
try:
version = sys.version_info # we might not even have this function! :)
if (version[0] < 2):
@@ -344,12 +344,12 @@ class Mbox(mailbox.UnixMailbox):
def exclusive_lock(self):
"""Set an advisory lock on the 'mbox' mailbox"""
vprint("obtaining exclusive lock on file '%s'" % self.mbox_file_name)
- fcntl.flock(self.mbox_file, fcntl.LOCK_EX)
+ fcntl.flock(self.mbox_file.fileno(), fcntl.LOCK_EX)
def exclusive_unlock(self):
"""Unset any advisory lock on the 'mbox' mailbox"""
vprint("dropping exclusive lock on file '%s'" % self.mbox_file_name)
- fcntl.flock(self.mbox_file, fcntl.LOCK_UN)
+ fcntl.flock(self.mbox_file.fileno(), fcntl.LOCK_UN)
def procmail_lock(self):
"""Create a procmail lockfile on the 'mbox' mailbox"""
@@ -537,7 +537,7 @@ class IdentityCache:
assert(msg)
message_id = msg.get('Message-ID')
assert(message_id)
- if message_id in self.seen_ids:
+ if self.seen_ids.has_key(message_id):
user_warning("duplicate message id: '%s' in mailbox '%s'" %
(message_id, self.mailbox_name))
self.seen_ids[message_id] = 1
diff --git a/setup.py b/setup.py
index 6528d79..265afd3 100755
--- a/setup.py
+++ b/setup.py
@@ -1,10 +1,11 @@
-#!/usr/bin/env python
+#! /usr/bin/env python
import sys
def check_python_version():
"""Abort if we are running on python < v2.0"""
- too_old_error = "This program requires python v2.0 or greater."
+ too_old_error = """This program requires python v2.0 or greater.
+Your version of python is: %s""" % sys.version
try:
version = sys.version_info # we might not even have this function! :)
if (version[0] < 2):
@@ -18,9 +19,8 @@ check_python_version() # define & run this early - 'distutils.core' is new
from distutils.core import setup
setup(name="archivemail",
- version="0.4.2",
+ version="0.4.3",
description="archive and compress old email",
- platforms="POSIX",
license="GNU GPL",
url="http://archivemail.sourceforge.net/",
author="Paul Rodger",
diff --git a/test_archivemail.py b/test_archivemail.py
index bd149e3..7ec41aa 100755
--- a/test_archivemail.py
+++ b/test_archivemail.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#! /usr/bin/env python
############################################################################
# Copyright (C) 2002 Paul Rodger <paul@paulrodger.com>
#
@@ -34,11 +34,15 @@ TODO: add tests for:
import sys
def check_python_version():
- """Abort if we are running on python < v2.0"""
- too_old_error = "This program requires python v2.0 or greater."
+ """Abort if we are running on python < v2.1"""
+ too_old_error = """This test script requires python version 2.1 or later.
+This is because it requires the pyUnit 'unittest' module, which only got
+released in python version 2.1. You should still be able to run archivemail on
+python versions 2.0 and above, however -- just not test it.
+Your version of python is: %s""" % sys.version
try:
version = sys.version_info # we might not even have this function! :)
- if (version[0] < 2):
+ if (version[0] < 2) or ((version[0] == 2) and (version[1] < 1)):
print too_old_error
sys.exit(1)
except AttributeError:
@@ -157,11 +161,11 @@ class TestMboxExclusiveLock(unittest.TestCase):
self.mbox.exclusive_lock()
file = open(self.mbox_name, "r+")
lock_nb = fcntl.LOCK_EX | fcntl.LOCK_NB
- self.assertRaises(IOError, fcntl.flock, file, lock_nb)
+ self.assertRaises(IOError, fcntl.flock, file.fileno(), lock_nb)
self.mbox.exclusive_unlock()
- fcntl.flock(file, lock_nb)
- fcntl.flock(file, fcntl.LOCK_UN)
+ fcntl.flock(file.fileno(), lock_nb)
+ fcntl.flock(file.fileno(), fcntl.LOCK_UN)
def tearDown(self):
if os.path.exists(self.mbox_name):
@@ -916,22 +920,22 @@ def make_message(body=None, default_headers={}, hours_old=None):
headers = copy.copy(default_headers)
if not headers:
headers = {}
- if 'Date' not in headers:
+ if not headers.has_key('Date'):
time_message = time.time() - (60 * 60 * hours_old)
headers['Date'] = time.asctime(time.localtime(time_message))
- if 'From' not in headers:
+ if not headers.has_key('From'):
headers['From'] = "sender@dummy.domain"
- if 'To' not in headers:
+ if not headers.has_key('To'):
headers['To'] = "receipient@dummy.domain"
- if 'Subject' not in headers:
+ if not headers.has_key('Subject'):
headers['Subject'] = "This is the subject"
- if 'From_' not in headers:
+ if not headers.has_key('From_'):
headers['From_'] = "%s %s" % (headers['From'], headers['Date'])
if not body:
body = "This is the message body"
msg = ""
- if 'From_' in headers:
+ if headers.has_key('From_'):
msg = msg + ("From %s\n" % headers['From_'])
del headers['From_']
for key in headers.keys():