python-2.7websocketgimppython-fu

GIMP Python and websockets


I've used GIMP 2 and WebSockets (in java and js) extensively, but I'm new to Python.

I want to use a websocket client in my gimp plugin, so I got myself Python 2.7.14 (which comes with pip), and I've run install instructions found on this websocket implementation: https://github.com/websocket-client/websocket-client

I saw that it depends on 'six' and 'backports.ssl_match_hostname', so I used pip to install both, six was already installed, and backports updated.

My plugin is as follows:

#!/usr/bin/env python

from gimpfu import *
import websocket

def python_pytest(img, layer) :
    # Actual plug-in code will go here
    ws = websocket.WebSocket()
    ws.connect("ws://example.com/websocket", http_proxy_host="proxy_host_name", http_proxy_port=3128)
    return

register(
    "python_fu_pytest", #Name so other scripts can find us
    "Collaborative Editing", #Short Desc
    "WebSocket based collaborative editing", #Long description
    "Jonathan Crowder", #Author
    "Open Source", #Copyright Holder
    "2017", #Copyright Date
    "NetCanvas", #Plugin name in menus
    "*", #Image types we can handle
    [], #Params shown to user
    [], #Return values
    python_pytest, #Main function
    menu="<Image>/NetCanvas") #Where to show in menus
main()

If I get rid of websocket related code, it appears to work just fine, but I get this error with the above code:

(gimp-2.8.exe:5508): LibGimpBase-WARNING **: gimp-2.8.exe: gimp_wire_read(): error
Querying plug-in: 'C:\Users\Jonathan\.gimp-2.8\plug-ins\netcanvas.py'

(gimp-2.8.exe:5508): LibGimpBase-WARNING **: gimp-2.8.exe: gimp_wire_read(): error

I'm no pilgrim to debugging, but there just isn't enough information for me to figure out whats going wrong. I got that output using command:

gimp-2.8 --verbose --console-messages

What am I doing wrong? Can gimp python plugins not read my installed libs? Is there a way to get more information out of gimp? I thought --verbose would actually be.. well, verbose.

Edit- Just to be clear, here is my entire log, incase you think I'm not including the juicy debugging information..:

INIT: gimp_load_config
Parsing 'C:\Users\Jonathan\.gimp-2.8\unitrc'
Parsing 'C:\Program Files\GIMP 2\etc\gimp\2.0\gimprc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\gimprc'
gimp_composite: verbose=no
Processor instruction sets: +mmx +sse +sse2 -3dnow -altivec -vis
Adding theme 'Default' (C:\Program Files\GIMP 2\share\gimp\2.0\themes\Default)
Adding theme 'Small' (C:\Program Files\GIMP 2\share\gimp\2.0\themes\Small)
Writing 'C:\Users\Jonathan\.gimp-2.8\themerc'
Trying splash 'C:\Users\Jonathan\.gimp-2.8\gimp-splash.png' ... failed
Trying splash 'C:\Program Files\GIMP 2\share\gimp\2.0\images\gimp-splash.png' ..
. OK
INIT: gimp_initialize
INIT: gimp_real_initialize
INIT: gui_initialize_after_callback
INIT: gimp_restore
Parsing 'C:\Users\Jonathan\.gimp-2.8\parasiterc'
Loading 'brush factory' data
Loading 'dynamics factory' data
Loading 'pattern factory' data
Loading 'palette factory' data
Loading 'gradient factory' data
Loading fonts
Loading 'tool preset factory' data
Parsing 'C:\Users\Jonathan\.gimp-2.8\templaterc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\modulerc'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcolor-selector-c
myk.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcolor-selector
-cmyk.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcolor-selector-w
ater.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcolor-selector
-water.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcolor-selector-w
heel.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcolor-selector
-wheel.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcontroller-dx-di
nput.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libcontroller-dx-
dinput.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter-c
olor-blind.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter
-color-blind.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter-g
amma.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter
-gamma.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter-h
igh-contrast.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter
-high-contrast.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter-l
cms.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter
-lcms.dll'
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter-p
roof.dll'
Unloading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter
-proof.dll'
INIT: gui_restore_callback
clipboard: writable pixbuf format: image/png
clipboard: writable pixbuf format: image/bmp
clipboard: writable pixbuf format: image/x-bmp
clipboard: writable pixbuf format: image/x-MS-bmp
clipboard: writable pixbuf format: image/x-icon
clipboard: writable pixbuf format: image/x-ico
clipboard: writable pixbuf format: image/x-win-bitmap
clipboard: writable pixbuf format: image/tiff
clipboard: writable pixbuf format: image/jpeg
Parsing 'C:\Users\Jonathan\.gimp-2.8\sessionrc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\dockrc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\toolrc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\contextrc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-rect-select-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-ellipse-select-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-free-select-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-fuzzy-select-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-by-color-select-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-iscissors-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-foreground-select-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-vector-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-color-picker-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-zoom-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-measure-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-move-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-align-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-crop-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-rotate-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-scale-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-shear-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-perspective-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-flip-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-cage-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-text-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-bucket-fill-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-blend-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-pencil-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-paintbrush-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-eraser-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-airbrush-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-ink-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-clone-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-heal-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-perspective-clone-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-convolve-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-smudge-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-dodge-burn-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-desaturate-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-color-balance-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-hue-saturation-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-colorize-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-brightness-contrast-tool'

Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-threshold-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-levels-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-curves-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-posterize-tool'
Parsing 'C:\Users\Jonathan\.gimp-2.8\tool-options\gimp-gegl-tool'
INIT: gimp_real_restore
Parsing 'C:\Users\Jonathan\.gimp-2.8\pluginrc'
Querying plug-in: 'C:\Program Files\GIMP 2\lib\gimp\2.0\plug-ins\pyconsole.py'

(gimp-2.8.exe:5508): LibGimpBase-WARNING **: gimp-2.8.exe: gimp_wire_read(): err
or
Querying plug-in: 'C:\Users\Jonathan\.gimp-2.8\plug-ins\netcanvas.py'

(gimp-2.8.exe:5508): LibGimpBase-WARNING **: gimp-2.8.exe: gimp_wire_read(): err
or
Writing 'C:\Users\Jonathan\.gimp-2.8\pluginrc'
Starting extension: 'extension-script-fu'
INIT: gui_restore_after_callback
Parsing 'C:\Users\Jonathan\.gimp-2.8\menurc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\devicerc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\controllerrc'
Parsing 'C:\Users\Jonathan\.gimp-2.8\colorrc'
loading menu 'C:\Program Files\GIMP 2\share\gimp\2.0\menus\image-menu.xml' for /
image-menubar
Loading module 'C:\Program Files\GIMP 2\lib\gimp\2.0\modules\libdisplay-filter-l
cms.dll'
EXIT: gimp_exit
EXIT: gui_exit_callback
Writing 'C:\Users\Jonathan\.gimp-2.8\sessionrc'
Writing 'C:\Users\Jonathan\.gimp-2.8\dockrc'
Writing 'C:\Users\Jonathan\.gimp-2.8\colorrc'
Writing 'C:\Users\Jonathan\.gimp-2.8\menurc'
Writing 'C:\Users\Jonathan\.gimp-2.8\controllerrc'
Writing 'C:\Users\Jonathan\.gimp-2.8\toolrc'
EXIT: gimp_real_exit
Writing 'C:\Users\Jonathan\.gimp-2.8\templaterc'
Writing 'C:\Users\Jonathan\.gimp-2.8\parasiterc'
Writing 'C:\Users\Jonathan\.gimp-2.8\unitrc'
EXIT: gui_exit_after_callback
EXIT: app_exit_after_callback
(Type any character to close this window)

Solution

  • On Windows Gimp comes with its own Python interpreter, so you either have to:

    Some hints do debug Gimp python scripts here.