aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Rodger <paul@paulrodger.com>2002-03-31 05:32:14 +0000
committerPaul Rodger <paul@paulrodger.com>2002-03-31 05:32:14 +0000
commit57ed36ea53817a011f3cc3173e6a66f8d879c479 (patch)
tree4f00679bb5c1882543f9d425676455d8d461980a
parent17bb56d33ce177234adab9db1d95eac11cb832d5 (diff)
downloadarchivemail-57ed36ea53817a011f3cc3173e6a66f8d879c479.tar.gz
archivemail-57ed36ea53817a011f3cc3173e6a66f8d879c479.tar.bz2
archivemail-57ed36ea53817a011f3cc3173e6a66f8d879c479.zip
Check the python version before we do an 'import atexit', because that
could fail on older versions.
-rwxr-xr-xarchivemail.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/archivemail.py b/archivemail.py
index 38c5b80..c5c2d70 100755
--- a/archivemail.py
+++ b/archivemail.py
@@ -22,6 +22,22 @@ Archive and compress old mail in mbox or maildir-format mailboxes.
Website: http://archivemail.sourceforge.net/
"""
+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."
+ try:
+ version = sys.version_info # we might not even have this function! :)
+ if (version[0] < 2):
+ print too_old_error
+ sys.exit(1)
+ except AttributeError:
+ print too_old_error
+ sys.exit(1)
+
+check_python_version() # define & run this early because 'atexit' is new
+
import atexit
import fcntl
import getopt
@@ -30,7 +46,6 @@ import os
import rfc822
import signal
import string
-import sys
import tempfile
import time
@@ -485,8 +500,6 @@ Website: http://archivemail.sourceforge.net/ """ % \
(_options.script_name, _options.days_old_max, _options.archive_suffix,
_options.script_name, _options.days_old_max)
- check_python_version()
-
args = _options.parse_args(args, usage)
if len(args) == 0:
print usage
@@ -806,18 +819,6 @@ def choose_temp_dir(mailbox_path):
temp_dir = os.curdir # use the current directory
return temp_dir
-def check_python_version():
- """Abort if we are running on python < v2.0"""
- build = sys.version
- too_old_error = "requires python v2.0 or greater. Your version is: %s" % build
- try:
- version = sys.version_info # we might not even have this function! :)
- if (version[0] < 2):
- unexpected_error(too_old_error)
- except: # I should be catching more specific exceptions
- unexpected_error(too_old_error)
-
-
def system_or_die(command):
"""Run the command with os.system(), aborting on non-zero exit"""
rv = os.system(command)