[Pythonmac-SIG] runtime version checks

Jack Jansen Jack.Jansen@oratrix.com
Thu, 20 Mar 2003 22:29:11 +0100


On donderdag, maa 20, 2003, at 21:26 Europe/Amsterdam, John P Speno 
wrote:

> Is there a portable way in Python 2.3a2 to discover if an application 
> is
> running from a .app bundle versus running from the command line?

I'm not sure whether this is in 2.3a2 already or only in CVS python, 
but there's
a new call MacOS.WMAvailable() that probably does what you want 
(although it
does not do what you say:-).

If the call returns true it is safe to do window manager calls. It will 
return
false in when you don't have a window manager (MacOSX Server, mac 
booted in
console mode), or don't have access to it (ssh'd to a machine where 
someone else
is logged in), or can't use the API's (running from the command line, 
and not with
the pythonw interpreter).

If you really need to test whether you run from a .app bundle I would 
check sys.executable.
--
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- Emma 
Goldman -