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

[Cluster-devel] conga/luci/utils luci_admin



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe 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


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