From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 27 Jun 2006 18:19:53 -0000 Subject: [Cluster-devel] conga/luci/utils luci_admin Message-ID: <20060627181953.21401.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2006-06-27 18:19:52 Modified files: luci/utils : luci_admin Log message: More informative messages when the Luci db can't be opened (f.e. when Luci is running) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/utils/luci_admin.diff?cvsroot=cluster&r1=1.20&r2=1.21 --- conga/luci/utils/luci_admin 2006/06/26 22:30:34 1.20 +++ conga/luci/utils/luci_admin 2006/06/27 18:19:52 1.21 @@ -159,14 +159,21 @@ db = DB(fs) db.pack() conn = db.open() - except: - stderr.write('Unable to open the Luci database \"' + dbfn + '\"\n') + except IOError, e: + if e[0] == 11: + sys.stderr.write('It appears that Luci is running. Please stop Luci before attempting to restore your installation.\n') + return -1 + else: + sys.stderr.write('Unable to open the Luci database \"' + dbfn + '\":' + str(e) + '\n') + return -1 + except Exception, e: + sys.stderr.write('Unable to open the Luci database \"' + dbfn + '\":' + str(e) + '\n') return -1 try: node = xml.dom.minidom.parse(backupfn) except: - stderr.write('Unable to open the Luci backup file \"'+ backupfn +'\"\n') + sys.stderr.write('Unable to open the Luci backup file \"'+ backupfn +'\"\n') return -1 node = node.getElementsByTagName('luci') @@ -477,8 +484,15 @@ db = DB(fs) db.pack() conn = db.open() - except: - stderr.write('Unable to open the luci database \"' + dbfn + '\"\n') + except IOError, e: + if e[0] == 11: + sys.stderr.write('It appears that Luci is running. Please stop Luci before attempting to backup your installation.\n') + return None + else: + sys.stderr.write('Unable to open the Luci database \"' + dbfn + '\":' + str(e) + '\n') + return None + except Exception, e: + sys.stderr.write('Unable to open the Luci database \"' + dbfn + '\":' + str(e) + '\n') return None examine_classes = [ @@ -872,7 +886,7 @@ try: os.rename(LUCI_BACKUP_PATH, oldbackup) except: - sys.write.stderr('Unable to rename the existing backup file.\n') + sys.stderr.stderr('Unable to rename the existing backup file.\n') sys.exit(1) break trynum += 1