This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ronaldoussoren
Recipients Arfrever, Hobson.Lane, Roman.Evstifeev, benjamin.peterson, cvrebert, eric.araujo, ganadist, giampaolo.rodola, larry, pitrou, r.david.murray, ronaldoussoren, rosslagerwall, smarnach, tebeka
Date 2012-07-31.16:03:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1343750614.61.0.0159128746572.issue3177@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-07-31 16:03:35ronaldoussorensetrecipients: + ronaldoussoren, tebeka, pitrou, larry, giampaolo.rodola, benjamin.peterson, eric.araujo, ganadist, Arfrever, r.david.murray, cvrebert, rosslagerwall, smarnach, Roman.Evstifeev, Hobson.Lane
2012-07-31 16:03:34ronaldoussorensetmessageid: <1343750614.61.0.0159128746572.issue3177@psf.upfronthosting.co.za>
2012-07-31 16:03:34ronaldoussorenlinkissue3177 messages
2012-07-31 16:03:33ronaldoussorencreate