On Thu, Apr 14, 2011 at 2:56 PM, Leandro Hermida <softdev@leandrohermida.com> wrote:
On Thu, Apr 14, 2011 at 3:17 PM, Peter Cock <p.j.a.cock@googlemail.com> wrote:
For standard Python tools in Galaxy, I'm using os.path.split(sys.argv[0])[0] to get the path, which on reflection probably should be written as os.path.dirname(sys.argv[0]) as you suggest.
What do __file__ and sys.argv[0] give you? The simplest way to debug this is to add a print statement, since Galaxy will show the stdout.
Hi Peter,
__file__ throws an error: global name '__file__' is not defined
I guess the script is being loaded as a string, and run with eval(...) or something like that. It would also explain why sys.argv[0] would be one of the Galaxy script files.
os.path.abspath(os.path.dirname(sys.argv[0])) gives me /path/to/galaxy/scripts directory which is two levels up from what the tool directory I want for example /path/to/galaxy/tools/mytool
So combine that with ../tools/mytool/ and you're done? OK, you have to know the name of the folder your tool *should* be in... so not a perfect solution. Peter