[Python-au] python library to discover file associations

Ben Golding bgg at object-craft.com.au
Tue Feb 22 03:20:00 UTC 2011


On 22/02/2011, at 13:36, Mike Dewhirst wrote:

> Here is my code ...
> 
>        if obj.main():
>            cmd = '%s' % obj.logname
>            subprocess.Popen(cmd, shell=True).wait()
> 
> ... which now works without error unless obj.logname has a non-specific filename extension. At that point I get ...
> 
>  File "subprocess.pyo", line 486, in call
>  File "subprocess.pyo", line 672, in __init__
>  File "subprocess.pyo", line 882, in _execute_child
> WindowsError: [Error 193] %1 is not a valid Win32 application
> 
> I think I'll put that in a try block and if I detect any such OSError I'll take a stab with Notepad on Windows or Nano on Linux.
> 
> What should I try for on Mac?

On Linux or mac you probably should be using the environment variable EDITOR, that way people can change it if they want to.

	Ben.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3589 bytes
Desc: not available
URL: <http://starship.python.net/pipermail/python-au/attachments/20110222/cd483b3e/attachment-0001.bin>


More information about the python-au mailing list