Added plugins dir

This commit is contained in:
Fabio Manganiello 2017-10-31 09:20:35 +01:00
parent 065fa65190
commit bc157a1d80
2 changed files with 30 additions and 0 deletions

6
lib/plugins/__init__.py Normal file
View file

@ -0,0 +1,6 @@
class Plugin(object):
def run(self, args):
raise NotImplementedError()
# vim:sw=4:ts=4:et:

View file

@ -0,0 +1,24 @@
import subprocess
from .. import Plugin
class ShellPlugin(Plugin):
def run(self, args):
if 'cmd' not in args:
raise RuntimeError('No cmd parameter specified')
cmd = args['cmd']
output = None
error = None
try:
output = subprocess.check_output(cmd,
stderr=subprocess.STDOUT,
shell=True)
except subprocess.CalledProcessError as e:
error = e.output
return output, error
# vim:sw=4:ts=4:et: