1 """Launch programs using 0launch"""
6 class InjectorNotInstalled(Exception):
8 def __init__(self
, uri
):
10 Exception.__init
__(self
,
11 _("The program '%s' cannot be run, as the "
12 "0launch command is not available. "
13 "It can be downloaded from here:\n\n"
14 "http://0install.net/injector.html") % uri
)
17 """Runs a program using 0launch, and returns the PID.
18 If 0launch isn't installed, it raises InjectorNotInstalled,
19 telling the user how to get it."""
20 binpath
= os
.environ
.get('PATH', '').split(':')
21 # Try to run with '0launch'
22 for bindir
in binpath
:
23 path
= os
.path
.join(bindir
, '0launch')
24 if os
.path
.isfile(path
):
28 if not x
.startswith('-'):
29 raise InjectorNotInstalled(x
)
30 raise InjectorNotInstalled(repr(args
))
32 pid
= os
.spawnvp(os
.P_NOWAIT
, '0launch', ('0launch',) + args
)