On Thu, Apr 14, 2011 at 3:17 PM, Peter Cock <p.j.a.c...@googlemail.com>wrote:

> On Thu, Apr 14, 2011 at 2:08 PM, Leandro Hermida
> <soft...@leandrohermida.com> wrote:
> > Hi,
> >
> > I have a tool with a <code file="my_script.py"/> tag and in that code
> file
> > I'm trying to get the tool dirpath where that script and the tool XML
> > exist.  I've tried:
> >
> > os.path.abspath(os.path.dirname(sys.argv[0]))
> > os.path.abspath(os.path.dirname(__file__))
> >
> > And both don't work as expected. Is there a galaxy class I could import
> > which will have the tool directory path?
> >
> > regards,
> > Leandro
> 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
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

Isn't there some Galaxy class I can import? I remember seeing in other code
files "import galaxy" and would this have somewhere in it the current tool

Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:


Reply via email to