> Hi,
> I have attached a small patch for script-fu-server that makes the
> server return to the clients the output of the commands executed, just
> like the script-fu-console does.
> Is the patch ok? Any chance to apply it the mainline? Should I make a
> bug-report and attach the patch to it?
> Thanx,
> Ionutz

This is great stuff. If we had had this a year ago, it would have
saved me a *lot* of ugly hacking about developing the client side
gimp-mode for Emacs. (If you wanna know, this was done by
wrapping the code to be sent
inside scheme code that wrote back to a file, with stuff such as
tracing and the various write and display functions not working).
The other implementation I did to interact with GIMP was with GIMP as
a subprocess as
a batch program; this is quite crude and does not work under that other OS
I have to use at work.

Attached is a small python program (my first) I wrote this morning that gives
a simple REPL interface to the script-fu server based on your
patch, you might want to use that for testing if your patch works. So
far it is going strong.

I very much like to see this one implemented, and am working on
rewriting parts of gimp-mode for Emacs to use this facility. Even
though the script-fu server apparently was not intended for actual
use, its usefulness at least for developing script-fu inside an editor
of choice
is greatly enhanced with these additions.

It is looking promising.


#!/usr/bin/env python
import sys
import optparse
from socket import *
p = optparse.OptionParser(version="%prog 0.1")
p.add_option ("-p", "--port", type="int")
p.add_option ("-s", "--server", type="string")
opt, args = p.parse_args()

s = socket(AF_INET, SOCK_STREAM)
s.connect((opt.server, opt.port))

print "Welcome to GimpClient, Version 0.1"
print "Connected to server", opt.server, 'on port', opt.port, '\n'
print 60 * "-"

while (1):
    inp = raw_input("> ")
    if (inp == ',quit'):
    length = len(inp)
    if length > 65535:
        print 'Input too long'
        high = length / 256
        low = length % 256
        pre = "G" + chr(high) + chr(low) 
        s.send(pre + inp)

        magic = s.recv(1)[0]    
        error = ord(s.recv(1)[0])
        hbyte = ord(s.recv(1)[0])
        lbyte = ord(s.recv(1)[0])
        rlength = hbyte << 8 | lbyte
        tm = ''
        while (len(tm) < rlength):
            tm += s.recv(rlength - len(tm))
        print tm

Gimp-developer mailing list

Reply via email to