No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

core_scripts.py 1.3KB

123456789101112131415161718192021222324252627282930313233
  1. import lodel.plugin.scripts as lodel_script
  2. ##@brief Implements lodel_admin.py discover-plugin action
  3. #
  4. #In depth directory scan to find plugins.
  5. class DiscoverPlugin(lodel_script.LodelScript):
  6. _action = 'discover-plugin'
  7. _description = 'Walk through given folders looking for plugins'
  8. @classmethod
  9. def argparser_config(cls, parser):
  10. #parser.add_argument('-d', '--directory',
  11. parser.add_argument('PLUGIN_PATH',
  12. help="Directory to walk through looking for lodel2 plugins",
  13. nargs='+')
  14. parser.add_argument('-l', '--list-only', default=False,
  15. action = 'store_true',
  16. help="Use this option to print a list of discovered plugins \
  17. without modifying existing cache")
  18. @classmethod
  19. def run(cls, args):
  20. from lodel.plugin.plugins import Plugin
  21. if args.PLUGIN_PATH is None or len(args.PLUGIN_PATH) == 0:
  22. cls.help_exit("Specify a least one directory")
  23. no_cache = args.list_only
  24. res = Plugin.discover(args.PLUGIN_PATH, no_cache)
  25. print("Found plugins in : %s" % ', '.join(args.PLUGIN_PATH))
  26. for pname, pinfos in res['plugins'].items():
  27. print("\t- %s(%s) in %s" % (
  28. pname, pinfos['version'], pinfos['path']))