MCPcopy
hub / github.com/pyload/pyload / reloadPlugins

Method reloadPlugins

module/plugins/PluginManager.py:361–432  ·  view source on GitHub ↗

reloads and reindexes plugins

(self, type_plugins)

Source from the content-addressed store, hash-verified

359
360
361 def reloadPlugins(self, type_plugins):
362 """ reloads and reindexes plugins """
363
364 def merge(dst, src, overwrite=False):
365 """merge dict of dicts"""
366 for name in src:
367 if name in dst:
368 if overwrite is True:
369 dst[name].update(src[name])
370 else:
371 for _k in set(src[name].keys()) - set(dst[name].keys()):
372 dst[name][_k] = src[name][_k]
373 else:
374 dst[name] = src[name]
375
376
377 if not type_plugins: return False
378
379 self.log.debug("Request reload of plugins: %s" % type_plugins)
380
381 as_dict = {}
382 for t,n in type_plugins:
383 if t in as_dict:
384 as_dict[t].append(n)
385 else:
386 as_dict[t] = [n]
387
388 # we do not reload hooks or internals, would cause to much side effects
389 if "hooks" in as_dict or "internal" in as_dict:
390 return False
391
392 for type in as_dict.iterkeys():
393 for plugin in as_dict[type]:
394 if plugin in self.plugins[type]:
395 if "module" in self.plugins[type][plugin]:
396 self.log.debug("Reloading %s" % plugin)
397 reload(self.plugins[type][plugin]["module"])
398
399 #index creation
400 self.crypterPlugins , config = self.parse("crypter", pattern=True)
401 self.plugins["crypter"] = self.crypterPlugins
402 default_config = config
403
404 self.containerPlugins, config = self.parse("container", pattern=True)
405 self.plugins["container"] = self.containerPlugins
406 merge(default_config, config)
407
408 self.hosterPlugins, config = self.parse("hoster", pattern=True)
409 self.plugins["hoster"] = self.hosterPlugins
410 merge(default_config, config)
411
412 self.captchaPlugins, config = self.parse("captcha")
413 self.plugins["captcha"] = self.captchaPlugins
414 merge(default_config, config)
415
416 self.accountPlugins, config = self.parse("accounts")
417 self.plugins["accounts"] = self.accountPlugins
418 merge(default_config, config)

Callers 2

autoreload_pluginsMethod · 0.80
update_pluginsMethod · 0.80

Calls 9

parseMethod · 0.95
itemsMethod · 0.80
popMethod · 0.80
addPluginConfigMethod · 0.80
initPluginsMethod · 0.80
addJobMethod · 0.80
appendMethod · 0.45
iterkeysMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected