Exemplo n.º 1
0
Arquivo: cli.py Projeto: anthonyt/3ad
 def __init__(self, namespace=None):
     ColoredManhole.__init__(self, namespace)
     self.completer = Completer(namespace=self.namespace)
     self.completeState = 0
     self.lastTabbed = ''
     self.lastSuggested = ''
     self.sem = defer.DeferredLock()
     self.enabled = True
Exemplo n.º 2
0
 def __init__(self, *a, **kw):
     ColoredManhole.__init__(self, *a, **kw)
     #Define namespace and populate it with instances of the base commands
     self.namespace = {
         'help': Help.HelpHooker(config),  #This needs to be changed
         'show': Show.Show(config),
         'config': Set.Config(config),
         'service': Service.Service(config),
     }
     """Thanks colin for the plugin stuff"""
     dirList = os.listdir("Console/plugins/")
     for pluginFileName in dirList:
         if ".py" == pluginFileName[
                 -3:] and not "__init__" in pluginFileName:
             try:
                 """File is therefore a valid .py file and should be loaded into memory"""
                 consolePlugin = __import__(
                     "Console.plugins." + pluginFileName.replace('.py', ''),
                     globals(), locals(), ['plugins']).Plugin(config)
                 if len(consolePlugin.name) > 0:
                     """At this point we could add in some checks to see if the user should have access
                        however for the moment I am just going to hook the plugin directly into the subnamespace"""
                     [
                         self.namespace[actionName].attachHook(
                             consolePlugin)
                         for actionName in self.namespace.keys()
                     ]
                     print "[Console] Loaded Plugin: %s(%s)" % (
                         pluginFileName, consolePlugin.name)
                 else:
                     print "[Console] Invalid Plugin(name attribute is invalid):", pluginFileName
                     continue
             except Exception, e:
                 print "[Console] Invalid Plugin(%s): %s" % (e,
                                                             pluginFileName)
                 continue