Skip to content

cgarjun/pyplug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated

This package is deprecated in favour of https://github.com/cgarjun/plugd plugd is actually been used in production

PyPlug

This is simple plugin system based out of python, you can basically pass a config file with all necessary requirements and get the plugins to be executed

Requirements

Python 2.7+
pip install PyYaml

example_config

Simple example of how config should be formatted. This is basically yaml format and easy human readable

pluginpath: D:\development\pyplug\example_plugins
plugins:
  plugin_name_a:
    enable: true
    args:
      arg_a: blah
      arg_b: hello

  plugin_name_b:
    enable: false

  plugin_name_c:
    enable: true
    args:
      arg_a: blah
      arg_b: hello

example_plugins

This is also extremly simple make any python file with a main function

Usage

from pyplug import PluginManager

pm = PluginManager('../example_config/plugins.yaml')
pm.runPlugins()
or
pm.runPlugin('plugin_b')

List all availabel plugins from the config

pm.listPlugins()
['plugin_a', 'plugin_b']

Get the plugin object separate and execute it independent

pl = pm.getPlugin('plugin_a')
print pl.enable
True
print pl.args
{'arg_a': 'blah', 'arg_b': 'hello'}


pl.execute()