Browse Source

Merge branch 'feature/plugin' of github.com:rtCamp/easyengine into feature/plugin

feature/plugin
harshadyeola 10 years ago
parent
commit
083681e01b
  1. 5
      config/plugins.d/plugin.conf
  2. 84
      ee/cli/plugins/plugin.py
  3. 12
      ee/core/api_return.py
  4. 1
      setup.py

5
config/plugins.d/plugin.conf

@ -0,0 +1,5 @@
### Example Plugin Configuration for EasyEngine
[plugin]
enable_plugin = true

84
ee/cli/plugins/plugin.py

@ -0,0 +1,84 @@
"""EasyEngine plugin manager"""
from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.api_return import api_return
import pip
def ee_plugin_hook(app):
# do something with the ``app`` object here.
pass
class EEPluginController(CementBaseController):
class Meta:
label = 'plugin'
stacked_on = 'base'
stacked_type = 'nested'
description = 'plugin manager for EasyEngine'
arguments = [
(['-y', '--yes'],
dict(help='Default yes action', action='store_true')),
(['plugin_name'],
dict(help='Plugin name to install/uninstall/search/upgrade',
nargs='?')),
]
usage = "ee plugin (command) [options]"
@expose(hide=True)
def default(self):
"""default action of ee plugin command"""
self.app.args.print_help()
@expose(help="Install plugins")
def install(self):
url = ("http://epm.rtcamp.net:3000/info?name={0}"
.format(self.app.pargs.plugin_name))
pinfo = api_return(url)
try:
pip.main(['install', pinfo[0]['file']])
except Exception as e:
return False
@expose(help="Uninstall plugin")
def uninstall(self):
"""Start Uninstallation of plugins"""
pass
@expose(help="List installed plugins")
def list(self):
"""List installed plugins"""
pass
@expose(help="Search plugins")
def search(self):
"""Search plugins into EPM respository"""
pass
@expose(help="Upgrade installed plugins")
def upgrade(self):
"""Upgrade installed plugins"""
pass
@expose(help="Display package information")
def info(self):
"""Display package information"""
pass
@expose(help="Enable installed plugin")
def enable(self):
"""Enable installed plugin"""
pass
@expose(help="Disable installed plugin")
def disable(self):
"""Disable installed plugin"""
pass
def load(app):
# register the plugin class.. this only happens if the plugin is enabled
handler.register(EEPluginController)
# register a hook (function) to run after arguments are parsed.
hook.register('post_argument_parsing', ee_plugin_hook)

12
ee/core/api_return.py

@ -0,0 +1,12 @@
"""EasyEngine JSON to Dict"""
from urllib.request import urlopen
import json
def api_return(url):
try:
response = urlopen(url)
data = str(response.read().decode('utf-8'))
return json.loads(data)
except Exception as e:
return False

1
setup.py

@ -84,6 +84,7 @@ setup(name='ee',
'psutil',
'sh',
'sqlalchemy',
'pip',
],
data_files=[('/etc/ee', ['config/ee.conf']),
('/etc/ee/plugins.d', conf),

Loading…
Cancel
Save