Gimp-Forum.net
Python-fu path of the plug-ins folder - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP)
+---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions)
+---- Thread: Python-fu path of the plug-ins folder (/Thread-Python-fu-path-of-the-plug-ins-folder)



Python-fu path of the plug-ins folder - Davide_sd - 01-11-2019

Hello,

I'm using Python-fu to write a plugin. Is there any way to get the path of the plug-ins folder?


RE: Python-fu path of the plug-ins folder - Ofnuts - 01-11-2019

There isn't one single folder, there are "folders", so nothing says that the folder you are looking at is the right one (I use three additional folders besides the standard two, and furthermore they mostly contain soft links to script elsewhere.

If you want to know where your plugin is, use os.path.abspath(sys.argv[0]) (this is the full path to your plugin file..).

Code:
#!/usr/bin/env python
import os,sys
from gimpfu import *

def whoIam(case=None):
    me=sys.argv[0]
    case="Execution" if case is None else case
    print "----\n%s:\nsys.argv[0]=%s\nAbsolute=%s\nReal=%s" % (case,me,os.path.abspath(me),os.path.realpath(me))

whoIam(case='Initialization')

register(
    "whoiam","Who I am","Who I am", "", "", "", "WhoIAm","",[],[],whoIam,menu="<Image>/Test/"
)
main()
The code above will show you that your plugin code is fully executed everytime (you get the "Iniialization" output, besides the one called as the actual plugin function).


RE: Python-fu path of the plug-ins folder - Kevin - 01-11-2019

If you want to get the list of folders that are set in preferences:
Code:
pdb.gimp_gimprc_query("plug-in-path")



RE: Python-fu path of the plug-ins folder - Davide_sd - 01-16-2019

Thank you Kevin and Ofnuts for you replies. Very helpful! Smile