|
@@ -172,6 +172,9 @@ class Plugin(object):
|
172
|
172
|
|
173
|
173
|
##@brief Attribute that stores plugins list from discover cache file
|
174
|
174
|
_plugin_list = None
|
|
175
|
+
|
|
176
|
+ ##@brief Store dict representation of discover cache content
|
|
177
|
+ _discover_cache = None
|
175
|
178
|
|
176
|
179
|
##@brief Plugin class constructor
|
177
|
180
|
#
|
|
@@ -432,11 +435,29 @@ name differ from the one found in plugin's init file"
|
432
|
435
|
#@return a dict (see @ref _discover() )
|
433
|
436
|
@classmethod
|
434
|
437
|
def plugin_cache(cls):
|
435
|
|
- if not os.path.isfile(DISCOVER_CACHE_FILENAME):
|
436
|
|
- cls.discover()
|
437
|
|
- with open(DISCOVER_CACHE_FILENAME) as pdcache_fd:
|
438
|
|
- res = json.load(pdcache_fd)
|
439
|
|
- return res
|
|
438
|
+ if cls._discover_cache is None:
|
|
439
|
+ if not os.path.isfile(DISCOVER_CACHE_FILENAME):
|
|
440
|
+ cls.discover()
|
|
441
|
+ with open(DISCOVER_CACHE_FILENAME) as pdcache_fd:
|
|
442
|
+ res = json.load(pdcache_fd)
|
|
443
|
+ #Check consistency of loaded cache
|
|
444
|
+ if 'path_list' not in res:
|
|
445
|
+ raise LodelFatalError("Malformed plugin's discover cache file \
|
|
446
|
+: '%s'. Unable to find plugin's paths list." % DISCOVER_CACHE_FILENAME)
|
|
447
|
+ expected_keys = ['type', 'path', 'version']
|
|
448
|
+ for pname in res['plugins']:
|
|
449
|
+ for ekey in expected_keys:
|
|
450
|
+ if ekey not in res['plugins'][pname]:
|
|
451
|
+ #Bad cache !
|
|
452
|
+ logger.warning("Malformed plugin's discover cache \
|
|
453
|
+file : '%s'. Running discover again..." % DISCOVER_CACHE_FILENAME)
|
|
454
|
+ cls._discover_cache = cls.discover(res['path_list'])
|
|
455
|
+ break
|
|
456
|
+ else:
|
|
457
|
+ #The cache we just read was OK
|
|
458
|
+ cls._discover_cache = res
|
|
459
|
+
|
|
460
|
+ return cls._discover_cache
|
440
|
461
|
|
441
|
462
|
##@brief Register a new plugin
|
442
|
463
|
#
|