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,21 +221,21 @@ 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:
except Exception as e: self.ui.error("could not read intermediate mbnames file '%s':"
self.ui.error( "%s"% (intermediateFile, str(e)))
e, except Exception as e:
exc_info()[2], self.ui.error(
("intermediate mbnames file %s not properly read"% e,
intermediateFile) exc_info()[2],
) ("intermediate mbnames file %s not properly read"%
except OSError: intermediateFile)
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]