Brian C. Lane wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 04/27/2010 01:49 AM, Radek Vykydal wrote:
+ def read(self):
+ """Reads values from ifcfg file.
+
+ returns: number of values read
+ """
if not os.access(self.path, os.R_OK):
return None
Throwing an exception on open instead was intentional,
as it is really bad if we don't have access to the real
file (that's what the class is all about) - there is an assumption
that is quite related on in the stage 2 code that we have all ifcfg files
for network devices post stage1. Besides, it prevents from forgetting
to check return value of read. But maybe I'll reconsider it.
+ f = open(self.path, "r")
+ lines = f.readlines()
+ f.close()
+
+ for line in lines:
+ line = line.strip()
+ if line.startswith("#") or line == '':
+ continue
+ fields = line.strip().split('=', 2)
line is already stripped, so make this:
fields = line.split('=', 2)
right, thanks
+ # XXX hack
+ value = value.replace('"', '')
+ value = value.replace("'", '')
value = value.translate(None, "'\"")
yeah, that's better. I just copy and pasted this from method
used to read ifcfg files from another place (I remove it in later
patch) and didn't change it much for safety reasons.
+ fd, newifcfg = tempfile.mkstemp(prefix="ifcfg-%s" % self.iface, text=False)
I think it is possible for this to fail. You may want to wrap it in a
try: except: check
Maybe, but the fail is quite fatal, and I am a bit afraid of catching
exceptions sooner than it proves necessary. Additionally, the mkstemp
call is not caught at other places in anaconda.
Thanks for the review.
Radek
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list