From 9b67e56a547a7f2e7fd659978c5b6042b0dbbdfa Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Tue, 30 Nov 2010 22:35:39 +0000 Subject: [PATCH] Bug fixes for command support --- zeroinstall/injector/run.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zeroinstall/injector/run.py b/zeroinstall/injector/run.py index df5653e..c159bec 100644 --- a/zeroinstall/injector/run.py +++ b/zeroinstall/injector/run.py @@ -119,7 +119,6 @@ def execute_selections(selections, prog_args, dry_run = False, main = None, wrap if not dep_impl.id.startswith('package:'): _do_bindings(dep_impl, dep.bindings) - root_sel = sels[selections.interface] assert root_sel is not None @@ -135,6 +134,9 @@ def execute_selections(selections, prog_args, dry_run = False, main = None, wrap user_command = Command(qdom.Element(namespaces.XMLNS_IFACE, 'command', {'path': main}), None) commands = [user_command] + commands[1:] + if commands[-1].path is None: + raise SafeException("Missing 'path' attribute on ") + command_iface = selections.interface for command in commands: command_sel = sels[command_iface] @@ -152,17 +154,21 @@ def execute_selections(selections, prog_args, dry_run = False, main = None, wrap if command_path.startswith('/'): raise SafeException(_("Command path must be relative, but '%s' starts with '/'!") % command_path) - prog_path = os.path.join(_get_implementation_path(root_sel), command_path) + prog_path = os.path.join(_get_implementation_path(command_sel), command_path) assert prog_path is not None prog_args = [prog_path] + command_args + prog_args + runner = command.get_runner() + if runner: + command_iface = runner.interface + if not os.path.exists(prog_args[0]): raise SafeException(_("File '%(program_path)s' does not exist.\n" "(implementation '%(implementation_id)s' + program '%(main)s')") % - {'program_path': prog_args[0], 'implementation_id': root_sel.id, - 'main': commands[0].path}) + {'program_path': prog_args[0], 'implementation_id': command_sel.id, + 'main': commands[-1].path}) if wrapper: prog_args = ['/bin/sh', '-c', wrapper + ' "$@"', '-'] + list(prog_args) -- 2.11.4.GIT