[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[master 1/6] analog: handle a config file we can't open.



---
 scripts/analog |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/analog b/scripts/analog
index 7f2ba02..b392acd 100755
--- a/scripts/analog
+++ b/scripts/analog
@@ -157,8 +157,12 @@ if __name__ == "__main__":
     options.output = os.path.abspath(options.output)
     config = generate_rsyslog_config(options.port, directory)
     if options.output:
-        with open(options.output, 'w') as file:
-            file.write(config)
+        try:
+            with open(options.output, 'w') as file:
+                file.write(config)
+        except IOError as e:
+            print >> sys.stderr, "Can't write into file %s" % options.output
+            sys.exit(1)
         if options.stdout:
             pid = pid_location(options.port)
             print HINT % {
-- 
1.6.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]