From be8f972f605f5e387108e409f243c1ee7c0c87f7 Mon Sep 17 00:00:00 2001 From: Sebastian Goscik Date: Mon, 15 Feb 2016 15:11:38 +0000 Subject: [PATCH] Target: Added install_if_needed method This method will first search the target for a binary, only installing it, if one was not found. --- devlib/target.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/devlib/target.py b/devlib/target.py index 2b88589..46d4486 100644 --- a/devlib/target.py +++ b/devlib/target.py @@ -437,6 +437,14 @@ class Target(object): which = get_installed + def install_if_needed(self, host_path, search_system_binaries=True): + + binary_path = self.get_installed(os.path.split(host_path)[1], + search_system_binaries=search_system_binaries) + if not binary_path: + binary_path = self.install(host_path) + return binary_path + def is_installed(self, name): return bool(self.get_installed(name))