Re: [gentoo-portage-dev] [PATCH v2] NewsManager.getUnreadItems: handle EROFS (490732)

2014-11-17 Thread Brian Dolbec
On Fri, 14 Nov 2014 20:45:11 -0800
Zac Medico  wrote:

> When getUnreadItems tries to lock the news.unread file, it's safe to
> ignore EROFS. This is handled with a ReadOnlyFileSystem exception
> raised from the portage.locks.lockfile function.
> 
> X-Gentoo-Bug: 490732
> X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732
> ---
> This updated patch fixes the typo spotted by Brian Dolbec.
> 

LGTM, go for it.


but for future reference...


use brackets to group multiline imports instead of line continuations.

- from portage.exception import InvalidLocation, OperationNotPermitted, \ 
-   PermissionDenied
+ from portage.exception import (InvalidLocation, OperationNotPermitted,
+   PermissionDenied, ReadOnlyFileSystem)

-- 
Brian Dolbec 




[gentoo-portage-dev] [PATCH v2] NewsManager.getUnreadItems: handle EROFS (490732)

2014-11-14 Thread Zac Medico
When getUnreadItems tries to lock the news.unread file, it's safe to
ignore EROFS. This is handled with a ReadOnlyFileSystem exception
raised from the portage.locks.lockfile function.

X-Gentoo-Bug: 490732
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732
---
This updated patch fixes the typo spotted by Brian Dolbec.

 pym/portage/exception.py | 1 +
 pym/portage/locks.py | 7 ++-
 pym/portage/news.py  | 7 ---
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/pym/portage/exception.py b/pym/portage/exception.py
index ef62e7a..857a727 100644
--- a/pym/portage/exception.py
+++ b/pym/portage/exception.py
@@ -133,6 +133,7 @@ class AlarmSignal(TimeoutException):
 
 class ReadOnlyFileSystem(PortageException):
"""Read-only file system"""
+   from errno import EROFS as errno
 
 class CommandNotFound(PortageException):
"""A required binary was not available or executable"""
diff --git a/pym/portage/locks.py b/pym/portage/locks.py
index 0789f89..0b0f74b 100644
--- a/pym/portage/locks.py
+++ b/pym/portage/locks.py
@@ -16,7 +16,8 @@ import warnings
 import portage
 from portage import os, _encodings, _unicode_decode
 from portage.exception import DirectoryNotFound, FileNotFound, \
-   InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
+   InvalidData, TryAgain, OperationNotPermitted, PermissionDenied, \
+   ReadOnlyFileSystem
 from portage.util import writemsg
 from portage.localization import _
 
@@ -110,6 +111,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
raise OperationNotPermitted(func_call)
elif e.errno == PermissionDenied.errno:
raise PermissionDenied(func_call)
+   elif e.errno == ReadOnlyFileSystem.errno:
+   raise ReadOnlyFileSystem(func_call)
else:
raise
 
@@ -404,6 +407,8 @@ def hardlink_lockfile(lockfilename, 
max_wait=DeprecationWarning,
raise OperationNotPermitted(func_call)
elif e.errno == PermissionDenied.errno:
raise PermissionDenied(func_call)
+   elif e.errno == ReadOnlyFileSystem.errno:
+   raise ReadOnlyFileSystem(func_call)
else:
raise
else:
diff --git a/pym/portage/news.py b/pym/portage/news.py
index 0d72b00..d90d97a 100644
--- a/pym/portage/news.py
+++ b/pym/portage/news.py
@@ -1,5 +1,5 @@
 # portage: news management code
-# Copyright 2006-2013 Gentoo Foundation
+# Copyright 2006-2014 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 from __future__ import print_function, unicode_literals
@@ -28,7 +28,7 @@ from portage.localization import _
 from portage.locks import lockfile, unlockfile
 from portage.output import colorize
 from portage.exception import InvalidLocation, OperationNotPermitted, \
-   PermissionDenied
+   PermissionDenied, ReadOnlyFileSystem
 
 class NewsManager(object):
"""
@@ -180,7 +180,8 @@ class NewsManager(object):
unread_lock = None
try:
unread_lock = lockfile(unread_filename, 
wantnewlockfile=1)
-   except (InvalidLocation, OperationNotPermitted, 
PermissionDenied):
+   except (InvalidLocation, OperationNotPermitted, 
PermissionDenied,
+   ReadOnlyFileSystem):
pass
try:
try:
-- 
2.0.4