def main(): interactive = True advanced_enabled = True plugin_name = None if os.geteuid() != 0: fatal("confconsole needs root privileges to run") try: l_opts = ["help", "usage", "nointeractive", "plugin="] opts, args = getopt.gnu_getopt(sys.argv[1:], "hn", l_opts) except getopt.GetoptError as e: usage(e) for opt, val in opts: if opt in ("-h", "--help"): usage() elif opt == "--usage": advanced_enabled = False elif opt == "--nointeractive": interactive = False elif opt == "--plugin": plugin_name = val else: usage() em = plugin.EventManager() pm = plugin.PluginManager(PLUGIN_PATH, { 'eventManager': em, 'interactive': interactive }) if plugin_name: ps = filter(lambda x: isinstance(x, plugin.Plugin), pm.getByName(plugin_name)) if len(ps) > 1: fatal('plugin name ambiguous, matches all of %s' % ps) elif len(ps) == 1: p = ps[0] if interactive: tc = TurnkeyConsole(pm, em, advanced_enabled) tc.loop(dialog=p.path) # calls .run() else: p.module.run() else: fatal('no such plugin') else: tc = TurnkeyConsole(pm, em, advanced_enabled) tc.loop()
except getopt.GetoptError, e: usage(e) for opt, val in opts: if opt in ("-h", "--help"): usage() elif opt == "--usage": advanced_enabled = False elif opt == "--nointeractive": interactive = False elif opt == "--plugin": plugin_name = val else: usage() em = plugin.EventManager() pm = plugin.PluginManager(PLUGIN_PATH, {'eventManager': em, 'interactive': interactive}) if plugin_name: ps = filter(lambda x: isinstance(x, plugin.Plugin), pm.getByName(plugin_name)) if len(ps) > 1: fatal('plugin name ambiguous, matches all of %s' % ps) elif len(ps) == 1: p = ps[0] if interactive: tc = TurnkeyConsole(pm, em, advanced_enabled) tc.loop(dialog=p.path) # calls .run() else: