Re: [Pythonmac-SIG] Popen and py2app

2010-12-27 Thread Adam Morris
On Dec 28, 2010, at 12:24 PM, Aahz  wrote:

> Nope.  If you're doing that, just use os.path.exists() or isfile().
> Faster and safer.

I was hoping that I could detect it no matter where it was so advanced users 
could do symlinks or move it to their own folders or whatever which made me 
think of bash's which. You're right though, if I'm relegated to typing out the 
full path might as well use os.path.exists and allow the user to modify the 
path it looks in with a preference.
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Popen and py2app

2010-12-27 Thread Aahz
On Tue, Dec 28, 2010, Adam Morris wrote:
> On Dec 28, 2010, at 12:46 AM, Christopher Barker  
> wrote:
> 
>> I think you could specifically search for the utility in places it
>> might be expected to be found:
>>
>> /usr/bin
>> /usr/local/bin
>> /sw/... (for fink)
>> /opt/... (for macports)
> 
> That's the first thing I tried; maybe I typed wrong? I'll give it yet
> another look. ...
> 
> Right!
> 
> Understandably, I wrote "/usr/bin/which name" and it should be
> "/usr/bin/which /usr/local/bin/name".
> 
> Should have included the full path for the argument as well. Thanks!

Nope.  If you're doing that, just use os.path.exists() or isfile().
Faster and safer.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"Think of it as evolution in action."  --Tony Rand
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Popen and py2app

2010-12-27 Thread Adam Morris
On Dec 28, 2010, at 12:46 AM, Christopher Barker  wrote:

> I think you could specifically search for the utility in places it might be 
> expected to be found:
>
> /usr/bin
> /usr/local/bin
> /sw/... (for fink)
> /opt/... (for macports)

That's the first thing I tried; maybe I typed wrong? I'll give it yet
another look. ...

Right!

Understandably, I wrote "/usr/bin/which name" and it should be
"/usr/bin/which /usr/local/bin/name".

Should have included the full path for the argument as well. Thanks!
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Popen and py2app

2010-12-27 Thread Christopher Barker

Adam Morris wrote:

Could this be a problem with py2app, or is there something about the
run-time environment I've overlooked?

Would also be interested if there is a better way of checking to see
if a command line utility is currently located in the path for the
current user's system.


I think what you've done is correct -- i.e. it's not on the PATH for the 
users system.


For the most part, the PATH for the command line is added to the shell 
rc scripts, so if you are not running from a shell (i.e. from a py2app 
bundle) you won't have the additional entries on PATH (like /usr/local/bin).


I'm pretty sure there is a way to edit a plist somewhere to add to the 
PATH system (or user?) wide. However, if you're delivering an app 
bundle, you probably don't want to require your users to do this.


I may misunderstand your use case, but I think you could specifically 
search for the utility in places it might be expected to be found:


/usr/bin
/usr/local/bin
/sw/... (for fink)
/opt/... (for macports)

rather then expect it to be on the PATH.

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


[Pythonmac-SIG] Popen and py2app

2010-12-27 Thread Adam Morris
py2app experts,

I have a script that is packaged using and py2app that does a
pre-check to see if a command line utility is installed, using Popen
and "which name". (The script downloads and installs it if not.)

I pass subprocess.PIPE for stdout and stderr, with shell=True.

When I run the script "raw" from the terminal it always prints,
correctly, with the path to the desired utility, i.e.
('/usr/local/bin/name', '')

When I run the program after compiling with py2app, exactly as
documented on the website, the console always gets ('', '') as the
response, which is incorrect as it's definitely installed ... nor was
an error reported.

I even tried re-writing the Popen command as "/usr/bin/which name" to no avail.

Using 10.6.5, py2app 0.5.2.

Could this be a problem with py2app, or is there something about the
run-time environment I've overlooked?

Would also be interested if there is a better way of checking to see
if a command line utility is currently located in the path for the
current user's system.

(Just a hobbyist here, go easy on me!)

-Adam
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG