Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
add description, name for use in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbryner committed Jan 28, 2015
1 parent dfdb7a0 commit a5c2599
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions rest/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,47 +198,63 @@ def getPluginList(endpoint=None):
if endpoint is None:
for plugin in pluginList:
pdict = {}
pdict['title'] = plugin[0]
pdict['registration'] = plugin[2]
pdict['priority'] = plugin[3]
pdict['file'] = plugin[0]
pdict['name'] = plugin[1]
pdict['description'] = plugin[2]
pdict['registration'] = plugin[3]
pdict['priority'] = plugin[4]
pluginResponse.append(pdict)
else:
# filter the list to just the endpoint requested
for plugin in pluginList:
if endpoint in plugin[2]:
if endpoint in plugin[3]:
pdict = {}
pdict['title'] = plugin[0]
pdict['registration'] = plugin[2]
pdict['priority'] = plugin[3]
pdict['file'] = plugin[0]
pdict['name'] = plugin[1]
pdict['description'] = plugin[2]
pdict['registration'] = plugin[3]
pdict['priority'] = plugin[4]
pluginResponse.append(pdict)
return json.dumps(pluginResponse)


def registerPlugins():
'''walk the ./plugins directory
and register modules in pluginList
as a tuple: name,class,registration,priority
as a tuple: (mfile, mname, mdescription, mreg, mpriority, mclass)
'''

plugin_manager = pynsive.PluginManager()
if os.path.exists('plugins'):
modules = pynsive.list_modules('plugins')
for mname in modules:
module = pynsive.import_module(mname)
for mfile in modules:
module = pynsive.import_module(mfile)
reload(module)
if not module:
raise ImportError('Unable to load module {}'.format(mname))
raise ImportError('Unable to load module {}'.format(mfile))
else:
if 'message' in dir(module):
mclass = module.message()
mreg = mclass.registration


if 'priority' in dir(mclass):
mpriority = mclass.priority
else:
mpriority = 100
if 'name' in dir(mclass):
mname = mclass.name
else:
mname = mfile

if 'description' in dir(mclass):
mdescription = mclass.description
else:
mdescription = mfile

if isinstance(mreg, list):
print('[*] plugin {0} registered to receive messages from /{1}'.format(mname, mreg))
pluginList.append((mname, mclass, mreg, mpriority))
print('[*] plugin {0} registered to receive messages from /{1}'.format(mfile, mreg))
pluginList.append((mfile, mname, mdescription, mreg, mpriority, mclass))

def toUTC(suspectedDate, localTimeZone="US/Pacific"):
'''make a UTC date out of almost anything'''
Expand Down

0 comments on commit a5c2599

Please sign in to comment.