Ronald Oussoren added the comment:

MacOSX provides functionality simular to os.startfile in the LaunchServices 
framework. 

I've tried to prototype a startfile implementation using this framework, (see 
issue3177-os_startfile_macosx.txt) but I'm not too happy about it because the 
APIs don't actually work as expected.

In particular:

* The patch implements "open" (default), "edit", "print" and
  "explore" actions.

* "open" and "explore" work fine

* "edit" does not work as I'd expect because the function used
   to retrieve the default editor for a file returns the default
   application that can open the file, not necessarily one that
   claims to be an editor for the file-type. As an example, 
   'os.startfile("file.html", "edit")' starts Safari instead of
   an editor.

* "print" works for some file type, but not others (depending on 
  whether or not the target application implements the required
  AppleScript API)

* "execute" is untested, I haven't found an application yet that claims
  this role.

Other notes:

* This patch links Python with the ApplicationServices framework
  (which contains the LaunchServices framework)

* Because the API uses Apple's application frameworks users might get
  annoying crashes when calling this function in a subprocess.

* The code attached code is a prototype, it should be correct w.r.t.
  resource management, but isn't fully baked yet. One example of that
  is the use of a generic RuntimeError exception to signal problems,
  others are the lack of documentation and tests.

----------
nosy: +ronaldoussoren
Added file: http://bugs.python.org/file26624/issue3177-os_startfile_macosx.txt

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue3177>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to