From eadc444fd49644c02241ad18acedede62747010f Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Sun, 2 Jun 2013 08:46:08 -0500 Subject: bcfg2-info: Handle IOErrors Signed-off-by: Sol Jerome --- src/sbin/bcfg2-info | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 6aafd24d1..4e71ba35a 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -231,10 +231,14 @@ class InfoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore): print("Refusing to write files outside of /tmp without -f " "option") return - lxml.etree.ElementTree(self.BuildConfiguration(client)).write( - ofile, - encoding='UTF-8', xml_declaration=True, - pretty_print=True) + try: + lxml.etree.ElementTree(self.BuildConfiguration(client)).write( + ofile, + encoding='UTF-8', xml_declaration=True, + pretty_print=True) + except IOError: + err = sys.exc_info()[1] + print("Failed to write File %s: %s" % (ofile, err)) else: print(self._get_usage(self.do_build)) -- cgit v1.2.3-1-g7c22