RPC: Difference between revisions
Jump to navigation
Jump to search
(created) |
m (Server -> ServerProxy) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 10: | Line 10: | ||
<source lang="python"> | <source lang="python"> | ||
import xmlrpclib | try: | ||
srv = xmlrpclib. | # Python 2 | ||
import xmlrpclib | |||
except ImportError: | |||
# Python 3: | |||
import xmlrpc.client as xmlrpclib | |||
srv = xmlrpclib.ServerProxy('http://localhost:9123') | |||
srv.do('fetch 2xwu') | srv.do('fetch 2xwu') | ||
srv.do('as cartoon') | srv.do('as cartoon') | ||
srv.do('spectrum') | srv.do('spectrum') | ||
# or | |||
srv.fetch('2xwu') | |||
srv.show_as('cartoon') | |||
srv.spectrum() | |||
</source> | </source> | ||
Line 22: | Line 33: | ||
* [[Launching From a Script]] | * [[Launching From a Script]] | ||
* [[Launching PyMOL]] | * [[Launching PyMOL]] | ||
[[Category:Launching]] |
Latest revision as of 06:28, 26 September 2018
Remote control of PyMOL is possible with XML-RPC.
Launch PyMOL with the "-R" option to start the RPC server.
pymol -R
Connect from any client, using python:
try:
# Python 2
import xmlrpclib
except ImportError:
# Python 3:
import xmlrpc.client as xmlrpclib
srv = xmlrpclib.ServerProxy('http://localhost:9123')
srv.do('fetch 2xwu')
srv.do('as cartoon')
srv.do('spectrum')
# or
srv.fetch('2xwu')
srv.show_as('cartoon')
srv.spectrum()