Import and user interrupt exception handling added
authorPlamen Dimitrov <plamen.dimitrov@intra2net.com>
Thu, 28 Jun 2012 09:45:19 +0000 (11:45 +0200)
committerPlamen Dimitrov <plamen.dimitrov@intra2net.com>
Thu, 28 Jun 2012 09:45:19 +0000 (11:45 +0200)
fix_imap_internaldate.py

index bcf6dc2..cc46e4d 100644 (file)
@@ -15,8 +15,15 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 '''
 
+import sys
 import csv
-import argparse, configparser
+import argparse
+# python version handling
+try:
+    import configparser
+except ImportError:
+    print("This module needs python version 3 or later.")
+    sys.exit()
 import logging
 from mail_date_parser import MailDateParser
 from mail_iterator import MailIterator
@@ -44,7 +51,10 @@ def main():
         logging.info("Update mode initiated. Messages will be modified.")
 
     # proceed to main functionality
-    synchronize_csv(config, args.test_mode)
+    try:
+        synchronize_csv(config, args.test_mode)
+    except KeyboardInterrupt:
+        logging.info("Script was interrupted by the user.")
 
     return