summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-03-25 08:57:10 -0700
committerZac Medico <zmedico@gentoo.org>2011-03-25 08:57:10 -0700
commit0a64f784003c11e151405b7f708d77770de0ed57 (patch)
treecabd9eecb871a12191f96f0a6e9a7e72ad86c875
parentfe6a9433426d284aabdf774376082fbed1741478 (diff)
downloadportage-0a64f784003c11e151405b7f708d77770de0ed57.tar.gz
portage-0a64f784003c11e151405b7f708d77770de0ed57.tar.bz2
portage-0a64f784003c11e151405b7f708d77770de0ed57.zip
PollScheduler: handle missing log directory
This can be triggered by AbstractPollTask._log_poll_exception(), as reported by Michael Haubenwallner <haubi@gentoo.org> for AIX.
-rw-r--r--pym/_emerge/PollScheduler.py35
1 files changed, 23 insertions, 12 deletions
diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py
index 8f4bd64b9..043f02a8b 100644
--- a/pym/_emerge/PollScheduler.py
+++ b/pym/_emerge/PollScheduler.py
@@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2
import gzip
+import errno
import logging
import select
import time
@@ -318,22 +319,32 @@ class PollScheduler(object):
# (like for parallel-fetch), then use the global value.
background = self._background
+ msg_shown = False
if not background:
writemsg_level(msg, level=level, noiselevel=noiselevel)
+ msg_shown = True
if log_path is not None:
- f = open(_unicode_encode(log_path,
- encoding=_encodings['fs'], errors='strict'),
- mode='ab')
-
- if log_path.endswith('.gz'):
- # NOTE: The empty filename argument prevents us from triggering
- # a bug in python3 which causes GzipFile to raise AttributeError
- # if fileobj.name is bytes instead of unicode.
- f = gzip.GzipFile(filename='', mode='ab', fileobj=f)
-
- f.write(_unicode_encode(msg))
- f.close()
+ try:
+ f = open(_unicode_encode(log_path,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='ab')
+ except IOError as e:
+ if e.errno not in (errno.ENOENT, errno.ESTALE):
+ raise
+ if not msg_shown:
+ writemsg_level(msg, level=level, noiselevel=noiselevel)
+ else:
+
+ if log_path.endswith('.gz'):
+ # NOTE: The empty filename argument prevents us from
+ # triggering a bug in python3 which causes GzipFile
+ # to raise AttributeError if fileobj.name is bytes
+ # instead of unicode.
+ f = gzip.GzipFile(filename='', mode='ab', fileobj=f)
+
+ f.write(_unicode_encode(msg))
+ f.close()
_can_poll_device = None