It is currently Thu Jul 04, 2024 5:20 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 12:05 am  (#1) 
Offline
GimpChat Member

Joined: Nov 21, 2010
Posts: 6
noob here.

Say there's a problem with a python script. e.g., I forgot a paren somewhere.
The result is that my plug-in isn't available on the menu. I presume because the script quit before it registered.

Where is that syntax error going?

If I could see the errors coming from the script, I could find the culprit faster.

Thanks.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 12:06 am  (#2) 
Offline
GimpChat Member

Joined: Nov 21, 2010
Posts: 6
Forgot to say:
Running GIMP 2.6.11 on Win 7.


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 1:32 am  (#3) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
A start would be to use the Python console in GIMP:

http://registry.gimp.org/node/24275

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 1:58 am  (#4) 
Offline
GimpChat Member

Joined: Nov 21, 2010
Posts: 6
Thanks, mahvin. There's a lot of useful information there that I was unaware of.

However, I couldn't find an answer to my question.

I'm trying to figure out: where do the python errors go when there is a syntax error in the script?


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 3:21 am  (#5) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4050
I don't know the answer to your question, specifically. I use NetBeans or IDLE to run/check syntax and indentation for errors.

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 4:19 am  (#6) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
john_whorfin wrote:
I'm trying to figure out: where do the python errors go when there is a syntax error in the script?

Greets John,

I'm not a GIMP python person and I don't know the direct answer to your question in Windows but interpreted languages, like python and scheme, normally direct output to the console (or to GUI message dialog). This is the case in Linux. If python-fu isn't displaying those messages in a GUI dialog or in the python-fu console, you might try redirecting GIMP messages to the Windows console.

gimp --console-messages

You can check "gimp --help" on your system to see which options are compiled in.

Here is my gimp --help
]$ gimp -help
Usage:
  gimp [OPTION...] [FILE|URI...]

GNU Image Manipulation Program

Help Options:
  -h, --help                          Show help options
  --help-all                          Show all help options
  --help-gegl                         Show GEGL Options
  --help-gtk                          Show GTK+ Options

Application Options:
  -v, --version                       Show version information and exit
  --license                           Show license information and exit
  --verbose                           Be more verbose
  -n, --new-instance                  Start a new GIMP instance
  -a, --as-new                        Open images as new
  -i, --no-interface                  Run without a user interface
  -d, --no-data                       Do not load brushes, gradients, patterns, ...
  -f, --no-fonts                      Do not load any fonts
  -s, --no-splash                     Do not show a startup window
  --no-shm                            Do not use shared memory between GIMP and plugins
  --no-cpu-accel                      Do not use special CPU acceleration functions
  --session=<name>                    Use an alternate sessionrc file
  -g, --gimprc=<filename>             Use an alternate user gimprc file
  --system-gimprc=<filename>          Use an alternate system gimprc file
  -b, --batch=<command>               Batch command to run (can be used multiple times)
  --batch-interpreter=<proc>          The procedure to process batch commands with
  -c, --console-messages              Send messages to console instead of using a dialog
  --pdb-compat-mode=<mode>            PDB compatibility mode (off|on|warn)
  --stack-trace-mode=<mode>           Debug in case of a crash (never|query|always)
  --debug-handlers                    Enable non-fatal debugging signal handlers
  --g-fatal-warnings                  Make all warnings fatal
  --dump-gimprc                       Output a gimprc file with default settings
  --display=DISPLAY                   X display to use


Another thought would be to try running GIMP with the --verbose option.

You could also try running the plug-in directly from the command line but I don't know the exact syntax for that in Windows, uses something like "gimp-console", I believe. Look for the those executables and check their options.

There are a couple of python "code checkers" out there like PyChecker or PyLint, which might be useful in debugging syntax errors.

Push comes to shove, start your plug-in as skeleton code and add small sections in at a time, testing as you go. :mrgreen:

Sorry I couldn't assist more but maybe some of those suggestions will help.

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 4:30 am  (#7) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
Oh, and a python editor with color syntax highlighting might be helpful too. I'm sure there are a few good freebies out there for the Windows platform.

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 9:42 am  (#8) 
Offline
GimpChat Member
User avatar

Joined: Oct 19, 2010
Posts: 376
Location: North Central Ohio, USA
Although I don't do much programming, check out notepad++ on sourceforge. It is a free text editor that is syntax-aware for many programming languages (about 50, by my count) from Ada to YAML. It can do syntax highlighting for the selected language, find mis-matched parens, change document encodings, does unicode, and much more - and it runs on Windows and on Linux under Wine. It might be helpful to you in finding errors in your program.

I used it when I was on Windows, and on Linux found it a big help opening those problem text files and code that sometimes gives gedit problems due to encoding issues. (Although not so helpful, it can even open most binary files.)

As of today, the most recent version is 5.8.4. See it here on Sourceforge. I see one of the commenters posted that "Notepad++ is to text editors what IrfranView is to image viewers." Having used both programs, I have to agree. That may or may not mean much to Linux users, but Irfanview is sort of a Swiss Army Knife image viewer and simple image editor for Windows that can open pretty much any image...and also runs on Linux under Wine.

_________________
Life Truth: #12
My cat is a worst typist than I am.


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Tue Nov 23, 2010 10:01 am  (#9) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 14182
I agree. I have been using notepad++ for 3 yrs now. It is great for viewing scripts and plugins also.
There is also Notepad++ portable, http://filepig.org/download/notepad_plus_plus_portable/

_________________
Image


Top
 Post subject: Re: How to know why a python plug-in is failing
PostPosted: Wed Nov 24, 2010 4:06 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Yes Notepad ++ is awesome.
I believe you can run any python script in a wsys command line window and see the errors there.cygwin works as well i believe.As long as you have python installed , and they see the path it should work.

Here is a command window through cygwin throwing an error for not finding certain files to run it.

Compaq_Owner@Family-Room ~
$ ./scrnshot_tearoff.py
Traceback (most recent call last):
File "./scrnshot_tearoff.py", line 43, in <module>
from gimpfu import *
ImportError: No module named gimpfu

Compaq_Owner@Family-Room ~
$

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts use in python of plug-in lighting

4

No new posts Attachment(s) GIMP Python-Fu Plug-in template

4

No new posts GIMP 2.10 doesn't install my python plug-ins

1

No new posts Plug-in crashes after OS upgrade: python version mismatch? maybe?

4

No new posts Convert GIMP plugin from Python 2 to Python 3

4



* Login  



Powered by phpBB3 © phpBB Group