From d3d1aee93c9c5f04612c9237d452e9885c10af6d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 17 Jun 2011 15:35:29 -0700 Subject: repoman: handle PermissionDenied from digestgen This will fix bug #371987. --- pym/portage/checksum.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'pym/portage/checksum.py') diff --git a/pym/portage/checksum.py b/pym/portage/checksum.py index f640fd9f1..eeb5995bb 100644 --- a/pym/portage/checksum.py +++ b/pym/portage/checksum.py @@ -29,8 +29,19 @@ def _generate_hash_function(hashtype, hashobject, origin="unknown"): @type filename: String @return: The hash and size of the data """ - f = open(_unicode_encode(filename, - encoding=_encodings['fs'], errors='strict'), 'rb') + try: + f = open(_unicode_encode(filename, + encoding=_encodings['fs'], errors='strict'), 'rb') + except IOError as e: + func_call = "open('%s')" % filename + if e.errno == errno.EPERM: + raise portage.exception.OperationNotPermitted(func_call) + elif e.errno == errno.EACCES: + raise portage.exception.PermissionDenied(func_call) + elif e.errno == errno.ENOENT: + raise portage.exception.FileNotFound(filename) + else: + raise blocksize = HASHING_BLOCKSIZE data = f.read(blocksize) size = 0 -- cgit v1.2.3-1-g7c22