mbnames: output message on errors while reading intermediate files

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-07-06 00:38:43 +02:00
parent 218b3802c0
commit b3209e38c0

View File

@ -35,9 +35,6 @@ _mbLock = Lock()
_mbnames = None _mbnames = None
def _is_enabled(conf):
return False
def add(accountname, folder_root, foldername): def add(accountname, folder_root, foldername):
global _mbnames global _mbnames
if _mbnames.is_enabled() is not True: if _mbnames.is_enabled() is not True:
@ -224,12 +221,14 @@ class _Mbnames(object):
def write(self): def write(self):
itemlist = [] itemlist = []
try:
for intermediateFile in self._iterIntermediateFiles(): for intermediateFile in self._iterIntermediateFiles():
try: try:
with open(intermediateFile, 'rt') as intermediateFD: with open(intermediateFile, 'rt') as intermediateFD:
for item in json.load(intermediateFD): for item in json.load(intermediateFD):
itemlist.append(item) itemlist.append(item)
except (OSError, IOError) as e:
self.ui.error("could not read intermediate mbnames file '%s':"
"%s"% (intermediateFile, str(e)))
except Exception as e: except Exception as e:
self.ui.error( self.ui.error(
e, e,
@ -237,8 +236,6 @@ class _Mbnames(object):
("intermediate mbnames file %s not properly read"% ("intermediate mbnames file %s not properly read"%
intermediateFile) intermediateFile)
) )
except OSError:
pass
itemlist.sort(key=self._func_sortkey) itemlist.sort(key=self._func_sortkey)
itemlist = [self._peritem % d for d in itemlist] itemlist = [self._peritem % d for d in itemlist]