Avoid exception if modules.json is corrupt
If modules.json is corrupt, currently a ValueError is thrown. Probably a warning should be shown and an empty dictionary should be returned.
ValueErrorTraceback (most recent call last)
<ipython-input-4-153ee78c8f95> in <module>()
----> 1 db = pytimber.LoggingDB()
/eos/user/m/mfittere/lib/python/pytimber/pytimber/pytimber.pyc in
__init__(self, appid, clientid, source, loglevel)
78
79 # Start JVM
---> 80 mgr = cmmnbuild_dep_manager.Manager('pytimber',
logging.WARNING)
81 mgr.start_jpype_jvm()
82
/cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/Wed/x86_64-slc6-gcc62-opt/lib/python2.7/site-packages/cmmnbuild_dep_manager/cmmnbuild_dep_manager.pyc
in __init__(self, pkg, lvl)
50 if pkg is not None:
51 if not self.is_installed(pkg):
---> 52 self.install(pkg)
53
54 def set_logging_level(self, lvl):
/cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/Wed/x86_64-slc6-gcc62-opt/lib/python2.7/site-packages/cmmnbuild_dep_manager/cmmnbuild_dep_manager.pyc
in install(self, *args)
282 ret = self.register(*args)
283 if ret:
--> 284 self.resolve()
285 return ret
286
/cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/Wed/x86_64-slc6-gcc62-opt/lib/python2.7/site-packages/cmmnbuild_dep_manager/cmmnbuild_dep_manager.pyc
in resolve(self)
321
322 deps = []
--> 323 modules = self._load_modules()
324
325 # Build the dependency list from all installed packages
/cvmfs/sft-nightlies.cern.ch/lcg/views/dev3/Wed/x86_64-slc6-gcc62-opt/lib/python2.7/site-packages/cmmnbuild_dep_manager/cmmnbuild_dep_manager.pyc
in _load_modules(self)
194 self.log.debug('loading {0}'.format(f))
195 with open(f, 'r') as fp:
--> 196 json_data = json.load(fp)
197 for k, v in json_data.items():
198 modules[k] = v
/cvmfs/sft.cern.ch/lcg/releases/Python/2.7.13-597a5/x86_64-slc6-gcc62-opt/lib/python2.7/json/__init__.pyc
in load(fp, encoding, cls, object_hook, parse_float, parse_int,
parse_constant, object_pairs_hook, **kw)
289 parse_float=parse_float, parse_int=parse_int,
290 parse_constant=parse_constant,
object_pairs_hook=object_pairs_hook,
--> 291 **kw)
292
293
/cvmfs/sft.cern.ch/lcg/releases/Python/2.7.13-597a5/x86_64-slc6-gcc62-opt/lib/python2.7/json/__init__.pyc
in loads(s, encoding, cls, object_hook, parse_float, parse_int,
parse_constant, object_pairs_hook, **kw)
337 parse_int is None and parse_float is None and
338 parse_constant is None and object_pairs_hook is
None and not kw):
--> 339 return _default_decoder.decode(s)
340 if cls is None:
341 cls = JSONDecoder
/cvmfs/sft.cern.ch/lcg/releases/Python/2.7.13-597a5/x86_64-slc6-gcc62-opt/lib/python2.7/json/decoder.pyc
in decode(self, s, _w)
362
363 """
--> 364 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
365 end = _w(s, end).end()
366 if end != len(s):
/cvmfs/sft.cern.ch/lcg/releases/Python/2.7.13-597a5/x86_64-slc6-gcc62-opt/lib/python2.7/json/decoder.pyc
in raw_decode(self, s, idx)
380 obj, end = self.scan_once(s, idx)
381 except StopIteration:
--> 382 raise ValueError("No JSON object could be decoded")
383 return obj, end
ValueError: No JSON object could be decoded