diff options
author | Jeremy Katz <katzj@redhat.com> | 2003-03-11 00:23:34 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2003-03-11 00:23:34 +0000 |
commit | e924532620b039324b6246e358fc883bedc423ec (patch) | |
tree | dfc86e8aaa526a32956782df0475ac7df13ac9f8 /anaconda_log.py | |
parent | cb9553478026256a0067cd321fb3ddbf1789bf03 (diff) | |
download | anaconda-e924532620b039324b6246e358fc883bedc423ec.tar.gz anaconda-e924532620b039324b6246e358fc883bedc423ec.tar.xz anaconda-e924532620b039324b6246e358fc883bedc423ec.zip |
first set of merges of s390 code to taroon branch. mail to follow to
anaconda-list with a brief run down of what was merged, what wasn't, etc.
s390 branch was tagged with taroon-merge-1 so that I can see what's new
after this merge as well
Diffstat (limited to 'anaconda_log.py')
-rw-r--r-- | anaconda_log.py | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/anaconda_log.py b/anaconda_log.py index f0a5424d0..13f4434ed 100644 --- a/anaconda_log.py +++ b/anaconda_log.py @@ -15,11 +15,13 @@ # import sys +import iutil class Anaconda_LogFile: def __init__ (self): self.logFile = None self.logFile2 = None + self.failcount = 0 def close (self): try: @@ -37,27 +39,39 @@ class Anaconda_LogFile: elif file: self.logFile = file else: - self.logFile = open("/dev/tty3", "w") + if iutil.getArch() != "s390": + self.logFile = open("/dev/tty3", "w") + else: + # we don't really want to have to write this stuff to two + # files. + self.logFile = None try: self.logFile2 = open("/tmp/anaconda.log", "a") except: - pass + self.logFile2 = None def __call__ (self, format, *args): if not self.logFile: raise RuntimeError, "log file not open yet" - - if args: - self.logFile.write ("* %s\n" % (format % args)) - else: - self.logFile.write ("* %s\n" % format) - if self.logFile2: + for file in [self.logFile, self.logFile2]: + if file is None: + continue if args: - self.logFile2.write ("* %s\n" % (format % args)) + file.write ("* %s\n" % (format % args)) else: - self.logFile2.write ("* %s\n" % format) - self.logFile2.flush() + file.write ("* %s\n" % format) + + try: + file.flush() + except IOError: + # if we can't write here, there's not much we can do. + # keep a counter of the number of times it's failed + # if we fail more than 10 times, just abort writing to + # the logfile + self.failcount = self.failcount + 1 + if self.failcount > 10: + file = None def getFile (self): return self.logFile.fileno () |