public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732)
@ 2014-11-10  6:30 Zac Medico
  2014-11-10  7:51 ` Brian Dolbec
  2014-11-15  4:45 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
  0 siblings, 2 replies; 5+ messages in thread
From: Zac Medico @ 2014-11-10  6:30 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: 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
---
 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..7bdf716 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732)
  2014-11-10  6:30 [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732) Zac Medico
@ 2014-11-10  7:51 ` Brian Dolbec
  2014-11-10  8:14   ` Zac Medico
  2014-11-15  4:45 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
  1 sibling, 1 reply; 5+ messages in thread
From: Brian Dolbec @ 2014-11-10  7:51 UTC (permalink / raw
  To: gentoo-portage-dev

On Sun,  9 Nov 2014 22:30:50 -0800
Zac Medico <zmedico@gentoo.org> 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
> ---
>  pym/portage/exception.py | 1 +
>  pym/portage/locks.py     | 7 ++++++-
>  pym/portage/news.py      | 7 ++++---
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
>...

>  		unread_lock = None
>  		try:
>  			unread_lock = lockfile(unread_filename,
> wantnewlockfile=1)
> -		except (InvalidLocation, OperationNotPermitted,
> PermissionDenied):
> +		except (InvalidLocation, OperationNotPermitted,
> PermissionDenied.
   typo...........^

 :)

> +			ReadOnlyFileSystem):
>  			pass
>  		try:
>  			try:



-- 
Brian Dolbec <dolsen>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732)
  2014-11-10  7:51 ` Brian Dolbec
@ 2014-11-10  8:14   ` Zac Medico
  0 siblings, 0 replies; 5+ messages in thread
From: Zac Medico @ 2014-11-10  8:14 UTC (permalink / raw
  To: gentoo-portage-dev

On 11/09/2014 11:51 PM, Brian Dolbec wrote:
>> +		except (InvalidLocation, OperationNotPermitted,
>> PermissionDenied.
>    typo...........^
> 
>  :)

Thank you. It passed syntax validation, though it's an obvious typo.

It's fixed in my git branch now:

	https://github.com/zmedico/portage/tree/bug_490732


-- 
Thanks,
Zac


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [gentoo-portage-dev] [PATCH v2] NewsManager.getUnreadItems: handle EROFS (490732)
  2014-11-10  6:30 [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732) Zac Medico
  2014-11-10  7:51 ` Brian Dolbec
@ 2014-11-15  4:45 ` Zac Medico
  2014-11-17 22:47   ` Brian Dolbec
  1 sibling, 1 reply; 5+ messages in thread
From: Zac Medico @ 2014-11-15  4:45 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: 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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [gentoo-portage-dev] [PATCH v2] NewsManager.getUnreadItems: handle EROFS (490732)
  2014-11-15  4:45 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
@ 2014-11-17 22:47   ` Brian Dolbec
  0 siblings, 0 replies; 5+ messages in thread
From: Brian Dolbec @ 2014-11-17 22:47 UTC (permalink / raw
  To: gentoo-portage-dev

On Fri, 14 Nov 2014 20:45:11 -0800
Zac Medico <zmedico@gentoo.org> 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 <dolsen>



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-11-17 22:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-10  6:30 [gentoo-portage-dev] [PATCH] NewsManager.getUnreadItems: handle EROFS (490732) Zac Medico
2014-11-10  7:51 ` Brian Dolbec
2014-11-10  8:14   ` Zac Medico
2014-11-15  4:45 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
2014-11-17 22:47   ` Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox