Oops. I though I answered to this. Obviously not. This is what I do (pythonic):
start a server, e.g. (*): python create_input_server.py localhost 12345 then connect open the socket in Coot: open_coot_listener_socket_with_timeout(12345, "localhost") Now you can pass commands to Coot (and receive return values). This is the socket way used in scheme as well. Looking at it now, I would probably rather go with the xmlrpc way phenix is using. Appears much simpler. Maybe some of these days.... B (*) create_input_server.py may not be in the distro but is available on google code *************************************************** Dr. Bernhard Lohkamp Assistant Professor Div. Molecular Structural Biology Dept. of Medical Biochemistry and Biophysics (MBB) Karolinska Institutet S-17177 Stockholm Sweden phone: (+46) 08-52487651 fax: (+46) 08-327626 email: [email protected] ________________________________________ From: Mailing list for users of COOT Crystallographic Software [[email protected]] on behalf of Paul Emsley [[email protected]] Sent: 05 March 2012 16:51 To: [email protected] Subject: Re: Coot remote control Hi Chris, Sorry for the delay [1] On 15/02/12 10:39, Chris Weichenberger wrote: > I have browsed Coot's online documentation searching for means of remote > control. My goal would be to send commands to a running Coot instance from a > Python script and it looks like the socket based approach mentioned in the > documentation '13.28 remote-control' might do the job. Yes. That was the plan. The idea indeed was to send coot executable commands from another process. > However, function > documentation is pretty sparse, yes, sorry about that. It was never taken up, so it was de-prioritized. > so I wonder if there is someone who has > already dealt with it and could provide some code snippets or a more in-depth > explanation of the functions like 'open-coot-listener-socket', > 'open-coot-listener-socket-with-timeout', 'coot-socket-timeout-func', > 'coot-listener-idle-function-proc', 'eval-socket-string' and related. Then elsewhere, you start a standard socket server. This is how I do it in scheme: (let ((s (socket PF_INET SOCK_STREAM 0))) (setsockopt s SOL_SOCKET SO_REUSEADDR 1) (bind s AF_INET INADDR_ANY 12345) Then, with the server in place, your coot is supposed to run something like: (open-coot-listener-socket-with-timeout 12345 "localhost") Then simply shove your python command strings constructed on the server down this socket. Python command string blocks should start with "# PYTHON" and end with "; end-transmission#\newline" (where #\newline is not literal, of course) Full disclosure: I have spend a few minutes trying to get this to work with a python socket server and it's not working as I hoped it would. Hmm... - maybe this is the problem into which the Phenix people ran some time ago. Paul. [1] Australia, NZ and illness.
