changeset 3098:a67e104828d1

fix logfile code for EACCESS errors (does not hide them, just logs and re-raises now)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 04 Feb 2008 14:34:46 +0100
parents a94959a2aae7
children 42f0eb176c8e
files MoinMoin/logfile/__init__.py
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/logfile/__init__.py	Sat Feb 23 02:10:14 2008 +0100
+++ b/MoinMoin/logfile/__init__.py	Mon Feb 04 14:34:46 2008 +0100
@@ -144,17 +144,17 @@
                 # Use binary mode in order to retain \r - otherwise the offset calculation would fail.
                 self._input = file(self.__filename, "rb", )
             except IOError, err:
-                if err.errno == 2: # POSIX errno.ENOENT "file not found"
-                    try:
-                        # XXX workaround if edit-log does not exist: just create it empty
-                        f = file(self.__filename, "ab")
-                        f.write('')
-                        f.close()
-                        self._input = file(self.__filename, "rb", )
-                        return self._input
-                    except:
-                        pass
-                    raise StopIteration
+                if err.errno == errno.ENOENT: # "file not found"
+                    # XXX workaround if edit-log does not exist: just create it empty
+                    # if this workaround raises another error, we don't catch
+                    # it, so the admin will see it.
+                    f = file(self.__filename, "ab")
+                    f.write('')
+                    f.close()
+                    self._input = file(self.__filename, "rb", )
+                else:
+                    logging.error("logfile: %r IOERROR errno %d (%s)" % (self.__filename, err.errno, os.strerror(err.errno)))
+                    raise
             return self._input
         elif name == "_output":
             self._output = codecs.open(self.__filename, 'a', config.charset)