Hello again, I just started with FS products and have trouble to figure some things out ...
From within zope I would like to call scripts that I provide in the product folder on the file system like eg.:
handle = os.popen('gnuplot %s/bin/loadgraphs.gplt' % product_folder, 'r') How can I get the path to the product folder? Thanks in advance! Greetings Roman
+-------[ Roman Klesel ]---------------------- | Hello again, | | I just started with FS products and have trouble to figure some things out ... | | >From within zope I would like to call scripts that I provide in the product folder on the file system like eg.: | | handle = os.popen('gnuplot %s/bin/loadgraphs.gplt' % product_folder, 'r') | | How can I get the path to the product folder? from Globals import package_home package_home(globals()) should give you what you need. -- Andrew Milton akm@theinternet.com.au
Roman Klesel schrieb:
Hello again,
I just started with FS products and have trouble to figure some things out ...
From within zope I would like to call scripts that I provide in the product folder on the file system like eg.:
handle = os.popen('gnuplot %s/bin/loadgraphs.gplt' % product_folder, 'r')
How can I get the path to the product folder? Thanks in advance!
see the __file__ variable in your module. for example via: os.path.dirname(os.path.abspath(__file__)) you get the absolute path of the directory where your module is. Complete it to: os.path.join(os.path.dirname(os.path.abspath(__file__)),'bin','loadgraphs.gplt') to get the full path of your file os independent (e.g. works the same with unix,windows,mac os...)
Hi Tino, Tino Wildenhain schrieb:
How can I get the path to the product folder? Thanks in advance!
see the __file__ variable in your module.
for example via:
os.path.dirname(os.path.abspath(__file__))
you get the absolute path of the directory where your module is. Complete it to:
os.path.join(os.path.dirname(os.path.abspath(__file__)),'bin','loadgraphs.gplt')
to get the full path of your file os independent (e.g. works the same with unix,windows,mac os...)
wow, yes also interesting. In case one needs to get the path of an individual module. For my current task I went with Andrew's proposal and used package_home(globals()). That seems to work well. But your suggestion will be helpful in some other thing I have in mind ... Thanks! Greetings Roman
participants (3)
-
Andrew Milton -
Roman Klesel -
Tino Wildenhain