aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-11-13 17:57:26 (GMT)
committerZac Medico <zmedico@gentoo.org>2012-11-13 17:57:26 (GMT)
commit0f51adcadce66e5ecdac4ce42148d725c6b7227d (patch)
treea8f26a6fc5ae18ee15eacd6b6a9878b899290891
parentelog/mod_save: wrap IOException for bug #441948 (diff)
downloadportage-0f51adcadce66e5ecdac4ce42148d725c6b7227d.zip
portage-0f51adcadce66e5ecdac4ce42148d725c6b7227d.tar.gz
portage-0f51adcadce66e5ecdac4ce42148d725c6b7227d.tar.bz2
elog/mod_save_summary: wrap IOError, bug #441948
-rw-r--r--pym/portage/elog/mod_save_summary.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py
index 347f66e..3ad1dd3 100644
--- a/pym/portage/elog/mod_save_summary.py
+++ b/pym/portage/elog/mod_save_summary.py
@@ -1,7 +1,8 @@
# elog/mod_save_summary.py - elog dispatch module
-# Copyright 2006-2011 Gentoo Foundation
+# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import errno
import io
import time
import portage
@@ -37,9 +38,21 @@ def process(mysettings, key, logentries, fulltext):
# TODO: Locking
elogfilename = elogdir+"/summary.log"
- elogfile = io.open(_unicode_encode(elogfilename,
- encoding=_encodings['fs'], errors='strict'),
- mode='a', encoding=_encodings['content'], errors='backslashreplace')
+ try:
+ elogfile = io.open(_unicode_encode(elogfilename,
+ encoding=_encodings['fs'], errors='strict'),
+ mode='a', encoding=_encodings['content'],
+ errors='backslashreplace')
+ except IOError as e:
+ func_call = "open('%s', 'a')" % elogfilename
+ if e.errno == errno.EACCES:
+ raise portage.exception.PermissionDenied(func_call)
+ elif e.errno == errno.EPERM:
+ raise portage.exception.OperationNotPermitted(func_call)
+ elif e.errno == errno.EROFS:
+ raise portage.exception.ReadOnlyFileSystem(func_call)
+ else:
+ raise
# Copy group permission bits from parent directory.
elogdir_st = os.stat(elogdir)