It is currently Thu Jul 04, 2024 4:56 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 6:02 am  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Hi everybody,
I have some (hopefully not insane...) curiosity on the subject.
1 - why are scripts in python handled as plug-ins? they are interpreted as scripts in scheme are, they are not compiled-executable (IMHO it would have been clearer to have three categories : .scm scripts, .py scripts and .exe plug-ins; -or not to proliferate interpreted and executables-)
2 - why there is no "refresh" function for the python scripts as for the scheme scripts? when there is some error in one script it's a very useful function
3 - when launching gimp in -verbose mode, if in a python scripts there is a formal error it simply does not appear instead of reporting the error found in it; so it is very difficult to find out the error, I know there is the console but it seems to be available only for the operations not for the parameters of the definition (yesterday I was trying to find out what was wrong with a PF_OPTION parameter and spent a lot of time, finally finding the solution in a French chat...)
I hope among those of you who like programming for gimp there is somebody who likes to give some answer to a novice...
Thanks

_________________
"Where am I ?"


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: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 7:37 am  (#2) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
dinasset wrote:
Hi everybody,
I have some (hopefully not insane...) curiosity on the subject.
1 - why are scripts in python handled as plug-ins? they are interpreted as scripts in scheme are, they are not compiled-executable (IMHO it would have been clearer to have three categories : .scm scripts, .py scripts and .exe plug-ins; -or not to proliferate interpreted and executables-)
2 - why there is no "refresh" function for the python scripts as for the scheme scripts? when there is some error in one script it's a very useful function
3 - when launching gimp in -verbose mode, if in a python scripts there is a formal error it simply does not appear instead of reporting the error found in it; so it is very difficult to find out the error, I know there is the console but it seems to be available only for the operations not for the parameters of the definition (yesterday I was trying to find out what was wrong with a PF_OPTION parameter and spent a lot of time, finally finding the solution in a French chat...)
I hope among those of you who like programming for gimp there is somebody who likes to give some answer to a novice...
Thanks

1) Because they are really executing as independent processes, like other plugins. A python plugin can do a lot more things than a Scheme script (previews in its own windows, direct pixel access, etc...)

2) Possible explanation: The scripts are self-contained, you can't change the script function without changing the script file, so refreshing the scripts only deals with the changed .scm files. On the other hand a plugin may be spread over several files, but Gimp only knows about the "main" executable, to it would have to unconditionally re-run all plugins to make sure. In practice, the refresh is only useful if you change the registration code... if you fix the code elsewhere, you can run the script again and it will use the new code.

3) If there is a registration error you are told (not even in verbose mode):
Traceback (most recent call last):
  File "/home/me/.gimp-2.6/plug-ins/bad-path-dump.py", line 115, in <module>
    domain=("gimp20-python", gimp.locale_directory)
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 228, in register
    "elements (%s given: %s)" % (len(ent), ent))
gimpfu.error: parameter definition must contain at least 4 elements (3 given: (1001, 12, (0, 3, 1)))

But it's not a problem of Gimp being verbose or terse, since the errors are printed by the failing plugin. Its a problem of displaying output. On Linux, if you start Gimp from a terminal, all errors are printed to the terminal. In Windows, programs with windows have nowhere to send their output. AFAIK, the gimp-console executable is meant to give them somewhere to display things. You can also use a try/except around the registration code and write the error message to some file.

You can weed out your major syntax blunders by running the script outside of Gimp:
python the_script.py

When it complains about gimpfu missing, then there are no more syntax errors.

_________________
Image


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 8:05 am  (#3) 
Offline
GimpChat Member
User avatar

Joined: Feb 17, 2013
Posts: 36
theoretically,
you should use a remote debugger
(remote means - that the debugger and your program are running in different instances, or even different computers).

the usage is fairly simple, but i can't recall it right now.
it depends on the debugger you chose.

i used a great text-based debugger for python in a similar situation
-- i think it was winpdb punto org


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 8:07 am  (#4) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
Thanks a lot Ofnuts!
from your reply to point 2, if I'm not wrong, I understood that if I change the code (not the registration) in a python script I can rerun it immediately without closing/re-opening gimp? excellent!
from your reply to point 3, if again I'm not wrong, I understood that if I run the python script with the command python (I have downloaded/installed Komodo so I can run the command) also the registration syntax will be checked? excellent again!
To have the traceback capability available under Linux also under Windows would be great (in fact, also giving to Windows an output file - as I did -, we get only what appeared on the console, nothing more, thus nothing about failing python scripts).
Thanks a lot again for your info!

_________________
"Where am I ?"


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 8:11 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
thanks keshefs! I'll have a search on winpdb...

_________________
"Where am I ?"


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 8:27 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
keshef
I gave just a first look to winpdb site, but because it seems to me a little bit complex, before continuing I have just one question to you: is winpdb able to debug also the gimp related instructions of the python script (and primarily the registration with all its parameters)? because, for checking the python code I have tools already, thanks

_________________
"Where am I ?"


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 9:39 am  (#7) 
Offline
GimpChat Member
User avatar

Joined: Feb 17, 2013
Posts: 36
Sorry !!!
i meant this debugger:

pudb (find it on pypi - i cant post links here yet)

i used this for several months and i loved it.
it's interface is a bit unusual, but makes sense eventualy.
it uses similar keyboard as most other debuggers i know.


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 9:51 am  (#8) 
Offline
Global Moderator
User avatar

Joined: Apr 07, 2010
Posts: 14182
keshef, you can post your link after your next post.

_________________
Image


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 9:57 am  (#9) 
Offline
Script Coder
User avatar

Joined: Oct 25, 2010
Posts: 4756
dinasset wrote:
Thanks a lot Ofnuts!
from your reply to point 2, if I'm not wrong, I understood that if I change the code (not the registration) in a python script I can rerun it immediately without closing/re-opening gimp? excellent!
from your reply to point 3, if again I'm not wrong, I understood that if I run the python script with the command python (I have downloaded/installed Komodo so I can run the command) also the registration syntax will be checked? excellent again!
To have the traceback capability available under Linux also under Windows would be great (in fact, also giving to Windows an output file - as I did -, we get only what appeared on the console, nothing more, thus nothing about failing python scripts).
Thanks a lot again for your info!
For 2) yes. For 3), no, running the script outside of Gimp only checks syntax errors. Invalid registration semantics are caught by gimpfu which you can't run at that point.

_________________
Image


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Mon Feb 18, 2013 11:48 am  (#10) 
Offline
GimpChat Member
User avatar

Joined: Jan 20, 2013
Posts: 14816
Location: roma, italy
to Ofnuts: thanks (I hoped also 3 was possible...sigh)

to keshef: so far I found the link but didn't succeed in installing PUDB, but anyway, before continuing, could you tell me whether you operate on win and whether PUDB is able to check also the semantic related to the gimp-fu implementation of python? thanks

_________________
"Where am I ?"


Top
 Post subject: Re: scripts in scheme, scripts in python, plug-ins
PostPosted: Tue Dec 24, 2013 3:43 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Feb 17, 2013
Posts: 36
dinasset wrote:
to Ofnuts: thanks (I hoped also 3 was possible...sigh)

to keshef: so far I found the link but didn't succeed in installing PUDB, but anyway, before continuing, could you tell me whether you operate on win and whether PUDB is able to check also the semantic related to the gimp-fu implementation of python? thanks


i was running it on Linux,

and i never tried it with Gimp-fu


Top
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Can someone please convert these two python scripts for Gimp 2.99.19

10

No new posts Attachment(s) What filters/scripts/plug-ins do you use the most?

7

No new posts Where to find links to older Gimp Scripts and plug ins

3

No new posts Incidentally, newbies, "scripts" and "plug-ins" implement "filters"

2

No new posts Attachment(s) very old scripts

11



* Login  



Powered by phpBB3 © phpBB Group