This page describes a custom user implementation of an XML-RPC server.
For PyMOL's built-in server, see RPC.
This server will enable any method in the 'cmd' module to be called remotely, as well as custom methods of the "pymol_interface" class (several examples of which are shown below). Other modules (such as util) could be wrapped using the same trick.
<source lang="python">
from pymol import cmd, util
from threading import Thread
from SimpleXMLRPCServer import SimpleXMLRPCServer
import cPickle
import os
import re
import string
def pymol_startup () :
print "Loading PyMOL XML-RPC extensions"
server = pymol_interface()
class pymol_xmlrpc_server (SimpleXMLRPCServer) :
def __init__ (self, addr, interface) :
self.interface = interface
SimpleXMLRPCServer.__init__(self, addr, logRequests=0)
def _dispatch (self, method, params) :
if not self.interface.enable_xmlrpc :
return -1
result = -1
func = None
if ..→