Differences between revisions 1 and 10 (spanning 9 versions)
Revision 1 as of 2006-05-10 09:04:39
Size: 975
Editor: cache2-2-ffm-vpn
Comment:
Revision 10 as of 2014-11-24 05:21:59
Size: 339
Editor: SMRWO
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
##language:en
== You want to know WHERE your .exe is ==
Why? Maybe, you are building a website and have a subdir ./static below the directory in which your .exe resides, from where you server all .css and .js that is static. Or, you put the logs right below the programs dir within ./log

=== Problem ===
You cannot rely on __FILE__, because __FILE__ is not there in the py2exed main-script.
You could try to rely on ".", the "Current Directory", but that only works if your application was started there. That may happen, but it is not guaranted.

=== Solution ===
{{{
import os
import jpath

if hasattr(sys,"frozen") and sys.frozen == "windows_exe":
    p=jpath.path(os.path.abspath(sys.executable)).dirname()
}}}


now p contains the directory where your exe resides, no matter from where your exe has been called (maybe it is in the path)

"jpath" is the famous path module from [http://www.jorendorff.com/articles/python/path/ "Jason Orendorff"]
Greetings! I am Paulita we totally dig that reputation. She is a place of work supervisor. Idaho is where we've been living institutions and individuals and I do not plan on changing it's. He is really fond of playing badminton but he doesn't notice the time now. See what's new on my website here: [[http://icargames.net|Icargames.net]]

Greetings! I am Paulita we totally dig that reputation. She is a place of work supervisor. Idaho is where we've been living institutions and individuals and I do not plan on changing it's. He is really fond of playing badminton but he doesn't notice the time now. See what's new on my website here: Icargames.net

WhereAmI (last edited 2014-11-24 16:42:41 by JimmyRetzlaff)