> diff --git a/iutil.py b/iutil.py > index 39d398a..da97256 100644 > --- a/iutil.py > +++ b/iutil.py > @@ -1014,6 +1019,63 @@ def reIPL(anaconda, loader_pid): > # or a two-item list with errorMessage and rebootInstr (=> shutdown) > return message > > +def stringFileContents (filename): > + try: > + data = None > + > + fp = open (filename) > + > + data = fp.read ().strip () > + > + fp.close () > + > + dataContents = "" > + > + for ch in data: > + if ch in string.printable: > + dataContents += ch > + else: > + dataContents = None > + break > + > + if dataContents is not None: > + return dataContents > + > + dataContents = "" > + > + for ch in data: > + dataContents += hex (ord (ch)) + " " > + > + return dataContents > + > + except Excception, e: > + > + return "ERROR" Note the "Excception" typo above. Speaking of exceptions, I don't really care for the style of just catching the top-level exception, as this tends to have the unintended consequence of hiding unrelated errors. Since this is a library function, I'd prefer to not handle exceptions in it and let the caller deal with that. Can you show me what the sample output from this function would be? I find the two loops over data a little odd. > +def dumpReIPLFiles (): > + try: > + filename = "/sys/firmware/reipl/reipl_type" > + > + if not os.path.isfile (filename): > + return > + > + type = stringFileContents (filename) > + > + reIPL_log.info ("%s = %s" % (filename, type,)) > + > + directory = "/sys/firmware/reipl/%s" % (type,) > + > + if not os.path.exists (directory): > + return > + > + for directoryFile in os.listdir (directory): > + contents = stringFileContents ("%s/%s" % (directory, directoryFile,)) > + > + reIPL_log.info ("%s/%s = %s" % (directory, directoryFile, contents,)) > + > + except Exception, e: > + log.info("dumpReIPLFiles: Caught exception %s", (e,)) The same comment about catching Exception applies here. Also I think that you're really only going to have an exception coming up from stringFileContents, since you check os.path.{isfile,exists} already. Otherwise, this method looks fine. - Chris _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list