diff --git a/lib/plugin.py b/lib/plugin.py index 2db67ab..bbb20a9 100644 --- a/lib/plugin.py +++ b/lib/plugin.py @@ -152,14 +152,8 @@ def _loadconfig(self, arg = []): # add command line args to the program options + build default configuration data defaultConf = '[' + self.name + ']\n' group = OptionGroup(app['parser'], self.name.capitalize() + " Options", self.desc) - if self.options.__class__ is dict: - tmp = [] - for option, value in self.options.items(): - tmp.append({option: value}) - self.options = tmp - #for option, value in self.options.items(): for option in self.options: - option, value = option.items()[0] + value = self.options[option] if len(value) == 3: help = value[0] + " " + value[2] + "" defaultConf += '; ' + value[0] + ' - choices: ' + value[2] + '\n' @@ -203,18 +197,18 @@ def _rpc(self, method, *args, **kwargs): #, module = None): # self = __import__(module) #elif module is not None: # self = module - + func = getattr(self, method) - + if "api_user" not in kwargs: api_user = "public" else: api_user = kwargs["api_user"] - + if app["debug"]: print method, "public function?", hasattr(func, "rpc_public") - + if api_user != "admin" and not hasattr(func, "rpc_public"): raise Exception('Method "' + method + '" not allowed') - + return func(*args) diff --git a/nmcontrol.py b/nmcontrol.py index 1ebceef..8368d33 100755 --- a/nmcontrol.py +++ b/nmcontrol.py @@ -7,6 +7,7 @@ import inspect import optparse import ConfigParser +import traceback app = {} def main(): @@ -62,12 +63,15 @@ def main(): module = re.sub(r'\.py$', '', module) modulename = re.sub(r'^'+modType, '', module).lower() try: + if app["debug"]: + print "launching", modType, module importedModule = __import__(module) importedClass = getattr(importedModule, module) app[modType+'s'][importedClass.name] = importedClass(modType) importedClass.app = app except Exception as e: print "Exception when loading "+modType, module, ":", e + traceback.print_exc() # parse command line options # Note: There should not be plugins and services with the same name diff --git a/plugin/pluginData.py b/plugin/pluginData.py index 33a5c9b..25b8b30 100644 --- a/plugin/pluginData.py +++ b/plugin/pluginData.py @@ -9,24 +9,24 @@ class pluginData(plugin.PluginThread): name = 'data' - options = [ - {'start': ['launch at startup', 1]}, - {'import.mode': ['Import data at launch', 'none', '']}, - {'import.from': ['Import data from', 'namecoin', '']}, - {'import.file': ['Import data from file ', 'data' + os.sep + 'namecoin.dat']}, - {'import.namecoin': ['Path of namecoin.conf', platformDep.getNamecoinDir() + os.sep + 'namecoin.conf']}, - - {'update.mode': ['Update mode', 'ondemand', '']}, - {'update.from': ['Update data from', 'namecoin', '']}, - {'update.freq': ['Update data if older than', '30m', '[h|m|s]']}, - {'update.file': ['Update data from file ', 'data' + os.sep + 'namecoin.dat']}, - {'update.namecoin': ['Path of namecoin.conf', platformDep.getNamecoinDir() + os.sep + 'namecoin.conf']}, - - {'export.mode': ['Export mode', 'none', '']}, - {'export.to': ['Export data to', 'file']}, - {'export.freq': ['Export data frequency', '1h', '[h|m|s]']}, - {'export.file': ['Export data to file ', 'data' + os.sep + 'namecoin.dat']}, - ] + options = { + 'start': ['launch at startup', 1], + 'import.mode': ['Import data at launch', 'none', ''], + 'import.from': ['Import data from', 'namecoin', ''], + 'import.file': ['Import data from file ', 'data' + os.sep + 'namecoin.dat'], + 'import.namecoin': ['Path of namecoin.conf', platformDep.getNamecoinDir() + os.sep + 'namecoin.conf'], + + 'update.mode': ['Update mode', 'ondemand', ''], + 'update.from': ['Update data from', 'namecoin', ''], + 'update.freq': ['Update data if older than', '30m', '[h|m|s]'], + 'update.file': ['Update data from file ', 'data' + os.sep + 'namecoin.dat'], + 'update.namecoin': ['Path of namecoin.conf', platformDep.getNamecoinDir() + os.sep + 'namecoin.conf'], + + 'export.mode': ['Export mode', 'none', ''], + 'export.to': ['Export data to', 'file'], + 'export.freq': ['Export data frequency', '1h', '[h|m|s]'], + 'export.file': ['Export data to file ', 'data' + os.sep + 'namecoin.dat'], + } helps = { 'getData': [1, 1, '', 'Get raw data of a name'], 'getValue': [1, 1, '', 'Get raw value of a name'],