# Distributed under the terms of the GNU General Public License v2
import gzip
+import errno
import logging
import select
import time
# (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