diff --git a/IPython/Extensions/ipy_completers.py b/IPython/Extensions/ipy_completers.py index 1eed962..cc7f8bb 100644 --- a/IPython/Extensions/ipy_completers.py +++ b/IPython/Extensions/ipy_completers.py @@ -64,10 +64,7 @@ def getRootModules(): return [] modules += sys.builtin_module_names - - #special modules that don't appear normally - modules.extend(['xml']) - + modules = list(set(modules)) if '__init__' in modules: modules.remove('__init__') @@ -88,7 +85,7 @@ def moduleList(path): folder_list = [] #folder_list = glob.glob(os.path.join(path,'*')) folder_list = [p for p in folder_list \ - if os.path.exists(os.path.join(p,'__init__.py'))\ + if os.path.exists(os.path.join(path, p,'__init__.py'))\ or p[-3:] in ('.py','.so')\ or p[-4:] in ('.pyc','.pyo')] diff --git a/IPython/Extensions/ipy_server.py b/IPython/Extensions/ipy_server.py new file mode 100644 index 0000000..cd4c55b --- /dev/null +++ b/IPython/Extensions/ipy_server.py @@ -0,0 +1,38 @@ +""" Simple TCP socket server that executes statements in IPython instance. + +Usage: + +import ipy_server +ipy_server.serve_thread(16455) + +Now, to execute the statements in this ipython instance, open a TCP socket +(port 16455), write out the statements, and close the socket. +You can use e.g. "telnet localhost 16455" or a script to do this. + +This is a bit like 'M-x server-start" or gnuserv in the emacs world. + +""" + +import IPython.ipapi +ip = IPython.ipapi.get() + +import SocketServer + +# user-accessible port +PORT = 8099 + +class IPythonRequestHandler(SocketServer.StreamRequestHandler): + def handle(self): + #print "connection from", self.client_address + inp = self.rfile.read().replace('\r\n','\n') + #print "Execute",inp + ip.runlines(inp) + +def serve(port = PORT): + server = SocketServer.TCPServer(("", port), IPythonRequestHandler) + print "ipy_server on TCP port", port + server.serve_forever() + +def serve_thread(port = PORT): + import thread + thread.start_new_thread(serve, (port,)) \ No newline at end of file diff --git a/doc/ChangeLog b/doc/ChangeLog index badb01a..2960523 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,9 +1,19 @@ +2007-12-28 Ville Vainio + + * ipy_server.py: TCP socket server for "remote control" of an IPython + instance. + 2007-12-28 Fernando Perez * IPython/dtutils.py: Add utilities for interactively running doctests. Still needs work to more easily handle the namespace of the package one may be working on, but the basics are in place. +2007-12-27 Ville Vainio + + * ipy_completers.py: Applied arno's patch to get proper list of + packages in import completer. Closes #196. + 2007-12-20 Ville Vainio * completer.py, generics.py(complete_object): Allow