Message157216
> The alternative is to call Popen(['xdg-open', etc.]) and check if we get ENOENT, but I don’t know if this would be non-ambiguous (for example, do we get ENOENT if xdg-open exists but not the file?).
It's unambiguous. Python itself never opens the target file, it just passes the filepath string along to the xdg-open command. If Popen raises EnvironmentError, then xdg-open could not be executed. If the target file is nonexistent, then xdg-open will exit with status 2 (see aforelinked manpage). Entirely different error mechanisms.
> A related question: what to do when we’re not on Windows nor Mac and xdg-open doesn’t exist? Raise NotImplemented?
Seems reasonable to me.
So, the failure cases are:
(1) Platform doesn't support this feature -> raise NotImplemented
(2) Target file doesn't exist
(3) Target file is inaccessible
(4) No application is associated with the file type in question
OS X and xdg-open report (2) and (4), does Windows?
OS X reports (3) indirectly/vaguely [generic exit status 1 w/ possibly unstable error message]; don't know what Windows and xdg-open do here. |
|
Date |
User |
Action |
Args |
2012-03-31 17:51:05 | cvrebert | set | recipients:
+ cvrebert, vstinner, giampaolo.rodola, benjamin.peterson, eric.araujo, ganadist, cool-RR, rosslagerwall, Roman.Evstifeev |
2012-03-31 17:51:05 | cvrebert | set | messageid: <1333216265.49.0.971968767396.issue3177@psf.upfronthosting.co.za> |
2012-03-31 17:51:04 | cvrebert | link | issue3177 messages |
2012-03-31 17:51:04 | cvrebert | create | |
|