Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] NewsManager.getUnreadItems: handle EROFS (490732)
Date: Sat, 15 Nov 2014 04:45:20
Message-Id: 1416026711-21913-1-git-send-email-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732) by Zac Medico
1 When getUnreadItems tries to lock the news.unread file, it's safe to
2 ignore EROFS. This is handled with a ReadOnlyFileSystem exception
3 raised from the portage.locks.lockfile function.
4
5 X-Gentoo-Bug: 490732
6 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732
7 ---
8 This updated patch fixes the typo spotted by Brian Dolbec.
9
10 pym/portage/exception.py | 1 +
11 pym/portage/locks.py | 7 ++++++-
12 pym/portage/news.py | 7 ++++---
13 3 files changed, 11 insertions(+), 4 deletions(-)
14
15 diff --git a/pym/portage/exception.py b/pym/portage/exception.py
16 index ef62e7a..857a727 100644
17 --- a/pym/portage/exception.py
18 +++ b/pym/portage/exception.py
19 @@ -133,6 +133,7 @@ class AlarmSignal(TimeoutException):
20
21 class ReadOnlyFileSystem(PortageException):
22 """Read-only file system"""
23 + from errno import EROFS as errno
24
25 class CommandNotFound(PortageException):
26 """A required binary was not available or executable"""
27 diff --git a/pym/portage/locks.py b/pym/portage/locks.py
28 index 0789f89..0b0f74b 100644
29 --- a/pym/portage/locks.py
30 +++ b/pym/portage/locks.py
31 @@ -16,7 +16,8 @@ import warnings
32 import portage
33 from portage import os, _encodings, _unicode_decode
34 from portage.exception import DirectoryNotFound, FileNotFound, \
35 - InvalidData, TryAgain, OperationNotPermitted, PermissionDenied
36 + InvalidData, TryAgain, OperationNotPermitted, PermissionDenied, \
37 + ReadOnlyFileSystem
38 from portage.util import writemsg
39 from portage.localization import _
40
41 @@ -110,6 +111,8 @@ def lockfile(mypath, wantnewlockfile=0, unlinkfile=0,
42 raise OperationNotPermitted(func_call)
43 elif e.errno == PermissionDenied.errno:
44 raise PermissionDenied(func_call)
45 + elif e.errno == ReadOnlyFileSystem.errno:
46 + raise ReadOnlyFileSystem(func_call)
47 else:
48 raise
49
50 @@ -404,6 +407,8 @@ def hardlink_lockfile(lockfilename, max_wait=DeprecationWarning,
51 raise OperationNotPermitted(func_call)
52 elif e.errno == PermissionDenied.errno:
53 raise PermissionDenied(func_call)
54 + elif e.errno == ReadOnlyFileSystem.errno:
55 + raise ReadOnlyFileSystem(func_call)
56 else:
57 raise
58 else:
59 diff --git a/pym/portage/news.py b/pym/portage/news.py
60 index 0d72b00..d90d97a 100644
61 --- a/pym/portage/news.py
62 +++ b/pym/portage/news.py
63 @@ -1,5 +1,5 @@
64 # portage: news management code
65 -# Copyright 2006-2013 Gentoo Foundation
66 +# Copyright 2006-2014 Gentoo Foundation
67 # Distributed under the terms of the GNU General Public License v2
68
69 from __future__ import print_function, unicode_literals
70 @@ -28,7 +28,7 @@ from portage.localization import _
71 from portage.locks import lockfile, unlockfile
72 from portage.output import colorize
73 from portage.exception import InvalidLocation, OperationNotPermitted, \
74 - PermissionDenied
75 + PermissionDenied, ReadOnlyFileSystem
76
77 class NewsManager(object):
78 """
79 @@ -180,7 +180,8 @@ class NewsManager(object):
80 unread_lock = None
81 try:
82 unread_lock = lockfile(unread_filename, wantnewlockfile=1)
83 - except (InvalidLocation, OperationNotPermitted, PermissionDenied):
84 + except (InvalidLocation, OperationNotPermitted, PermissionDenied,
85 + ReadOnlyFileSystem):
86 pass
87 try:
88 try:
89 --
90 2.0.4

Replies