Need Simple Way To Determine If File Is Executable

Tim Daneliuk tundra at tundraware.com
Mon Dec 18 14:00:35 EST 2006


Gabriel Genellina wrote:
> At Monday 18/12/2006 13:41, Tim Daneliuk wrote:
> 
>> I was working on a new release and wanted to add file associations
>> to it.  That is, if the user selected a file and double clicked or
>> pressed Enter, I wanted the following behavior (in the following
>> steps, "type" means nothing more than "a file whose name ends with
>> a particular string"):
>>
>> 1) If an association for that file type exists, run the associated 
>> program.
>>
>> 2) If an association for that file type does not exist:
>>
>>     a) If the file is not "executable", see if there is a "default"
>>        association defined and run that program if there is.
>>
>>     b) If the file *is* "executable", run it.
> 
> This is what os.startfile does. The underlying Win32 functions would be 

And on Windows, that's exactly what I use.

> ShellExecute, FindExecutable & their variants.
> Will you maintain your own registry for associations?

Yes, because I want common configuration syntax and runtime
semantics across FreeBSD, Linux, Windows, et al.  The only
semantic difference is that, on Windows, if my own association
is not found, then the Windows association will apply.  This
cannot be done in the *nix environment - at least not easily -
because there is no common association repository across the
various window managers, nor is there a startfile() type
call in the POSIX world.


This is implemented already and largely works as planned.
There are a few subtleties I want to work into the next
release, but things work as expected today...

-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra at tundraware.com
PGP Key:         http://www.tundraware.com/PGP/



More information about the Python-list mailing list