changeset 564:a61046da30a1

Check if config file exists and set destination of --config option to config_file
author Bjoern Ricks <bricks@intevation.de>
date Fri, 02 Sep 2011 10:25:59 +0000
parents a4efa91bc3b2
children 7de7869962ef
files bin/sendnotificationmails.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/bin/sendnotificationmails.py	Fri Sep 02 10:18:54 2011 +0000
+++ b/bin/sendnotificationmails.py	Fri Sep 02 10:25:59 2011 +0000
@@ -9,6 +9,8 @@
 """Send pending notification mails"""
 
 import os
+import os.path
+import sys
 import smtplib
 import email
 import email.Utils
@@ -36,7 +38,7 @@
                                                  "notification.cfg"))
     parser.add_option("--config", "--config-file",
                       help=("The configuration file."
-                            " Default notification.cfg"))
+                            " Default notification.cfg"), dest="config_file")
     return parser.parse_args()
 
 
@@ -73,6 +75,9 @@
 
 def main():
     options, args = parse_commandline()
+    if not os.path.exists(options.config_file):
+        print sys.stderr >> , "File not found: %s" % options.config_file
+        sys.exit(1)
     send_notification_mails(options.config_file)
 
 main()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)