Author: gnichols
Date: 2011-04-18 18:05:20 +0000 (Mon, 18 Apr 2011)
New Revision: 890
Modified:
trunk/v7/configfile.py
Log:
635973 - reboot test should set vmcore size before testing kdump
Modified: trunk/v7/configfile.py
===================================================================
--- trunk/v7/configfile.py 2011-04-18 16:45:12 UTC (rev 889)
+++ trunk/v7/configfile.py 2011-04-18 18:05:20 UTC (rev 890)
@@ -14,7 +14,7 @@
# Author: Greg Nichols
#
-# parse simple configles of the form:
+# parse simple config files of the form:
# <parametername> <value(s)>
@@ -63,14 +63,20 @@
def removeParameter(self, name):
if self.getParameter(name):
del self.parameters[name]
+ saveLines = list()
for line in self.lines:
- # skip comment lines
+ # skip/preserve comment lines
if line.strip() and line.strip()[0] == "#":
+ saveLines.append(line)
continue
- words = line.strip().split(" ")
- if words[0] and words[0] == name:
- self.lines.remove(line)
- self.modified = True
+ words = line.strip().split(" ")
+ if words and words[0] == name:
+ self.modified = True
+ else:
+ saveLines.append(line)
+ if self.modified:
+ self.lines = saveLines
+
def save(self):
if self.modified:
@@ -80,8 +86,16 @@
if __name__ == "__main__":
try:
- confFile = ConfigFile("/etc/rc.local")
+ confFile = ConfigFile("qq.txt")
+ confFile.removeParameter("net")
+ confFile.save()
+ print "------------------------"
confFile.dump()
+ confFile = ConfigFile("qq.txt")
+ confFile.addParameter("net", "asd")
+ confFile.save()
+ print "------------------------"
+ confFile.dump()
except Exception, exception:
print exception
exit(1)
Show replies by date