Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id 2F3C3E00D2E; Mon, 21 Nov 2016 06:55:49 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no * trust * [74.125.83.48 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Received: from mail-pg0-f48.google.com (mail-pg0-f48.google.com [74.125.83.48]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 6FB3EE009BF for ; Mon, 21 Nov 2016 06:55:32 -0800 (PST) Received: by mail-pg0-f48.google.com with SMTP id 3so131380553pgd.0 for ; Mon, 21 Nov 2016 06:55:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ykTAM9wfj7f9WyfiN6kYMtTuQGUBWL/jA4FU63OZUOI=; b=eDpXjLe6KO8NNsFtx1sQyI9zSoc7jR+DMETfLGIe5JULD9I8+v5fk0FGSwrOKaFNnq 7wA1i+1SzSPDKYtsANIHLwGhaIHPLkTlDQkSvz9NlMXN6dS+2vYmxzxH4dV1Nu+GFeWA Gu5vVvjuI9RO12cHSCJ4YFl3b9vB+J/5W8no6wk14WRh8gj9ynF5XRZstcIcR7GjNv6l lk1UWMbI5oXMeRXeOFQ+RFNnfzKn115YANnzeVGLbwIuN62yD9umMU96jNEwOhpMu0K/ T/A81fLqbKhooLUB3KcKEB8pkr8BV6iaL7mnfL8+zlBwVU9Jb1znsKPAREO8DvQiVDwV ydEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ykTAM9wfj7f9WyfiN6kYMtTuQGUBWL/jA4FU63OZUOI=; b=PxWHqB3AhsbuKsI16vXK0NKxOdtKmD3826xfwjXF1RwYhNx/ZDXlHSJ9HnrYI+WpZX 43fhYhQh9EYQrHBRVGf8+BjdJ9yvgW43IaQFBUVzD5Rr6/QOtkXYCZ1U94jAm0ZjzOrV EQ4XvBuzzplfpY60eOTQjlTw6xevN3W69OlZf//tYg2DNzs8VkJ9Pv8zI3m3smiBRNg9 6p7Ieo3v5zDVeNVIpmcOB9GdNlN1lbJeKZ7AH4F2OwRV9IQTlSfIjvdS6/KtVZ0+3ide FfxWpLxg/eQXIYaj/M17Iw6ZwE1CPKYS4IuwyfEAAkJOOCi+LoyI57mx+mWFV02uwn1S Yv7A== X-Gm-Message-State: AKaTC03qI+Wtth/I7YiZKbB2DITnVU6Q1pQr/1nNlW6qWnwuSDwIJ50x4osyw7QUdY0BkGFq X-Received: by 10.99.230.17 with SMTP id g17mr33023556pgh.82.1479740132161; Mon, 21 Nov 2016 06:55:32 -0800 (PST) Received: from orion.ger.corp.intel.com ([192.55.54.44]) by smtp.gmail.com with ESMTPSA id n25sm38332994pfi.33.2016.11.21.06.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Nov 2016 06:55:31 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Mon, 21 Nov 2016 14:55:14 +0000 Message-Id: <1479740115-5985-7-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479740115-5985-1-git-send-email-michael.g.wood@intel.com> References: <1479740115-5985-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 6/7] toaster: buildinfohelper fix _get_layer_version_for_dependency X-BeenThere: toaster@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Web based interface for BitBake List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2016 14:55:49 -0000 This function is simplified by not trying to handle replacing the regex and just compiling and using it for matching. - Fix typo in logger output with undefined variable - Fix pyflake errors Signed-off-by: Michael Wood --- bitbake/lib/bb/ui/buildinfohelper.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py index 43a1411..63c779e 100644 --- a/bitbake/lib/bb/ui/buildinfohelper.py +++ b/bitbake/lib/bb/ui/buildinfohelper.py @@ -965,9 +965,10 @@ class BuildInfoHelper(object): return task_information def _get_layer_version_for_dependency(self, pathRE): - """ Returns the layer in the toaster db that has a full regex match to the pathRE. - pathRE - the layer path passed as a regex in the event. It is created in - cooker.py as a collection for the layer priorities. + """ Returns the layer in the toaster db that has a full regex + match to the pathRE. pathRE - the layer path passed as a regex in the + event. It is created in cooker.py as a collection for the layer + priorities. """ self._ensure_build() @@ -975,19 +976,26 @@ class BuildInfoHelper(object): assert isinstance(layer_version, Layer_Version) return len(layer_version.local_path) - # we don't care if we match the trailing slashes - p = re.compile(re.sub("/[^/]*?$","",pathRE)) - # Heuristics: we always match recipe to the deepest layer path in the discovered layers - for lvo in sorted(self.orm_wrapper.layer_version_objects, reverse=True, key=_sort_longest_path): - if p.fullmatch(lvo.local_path): + # Our paths don't append a trailing slash + if pathRE.endswith("/"): + pathRE = pathRE[:-1] + + p = re.compile(pathRE) + # Heuristics: we always match recipe to the deepest layer path in + # the discovered layers + for lvo in sorted(self.orm_wrapper.layer_version_objects, + reverse=True, key=_sort_longest_path): + if p.fullmatch(os.path.abspath(lvo.local_path)): return lvo if lvo.layer.local_source_dir: - if p.fullmatch(lvo.layer.local_source_dir): + if p.fullmatch(os.path.abspath(lvo.layer.local_source_dir)): return lvo - #if we get here, we didn't read layers correctly; dump whatever information we have on the error log - logger.warning("Could not match layer dependency for path %s : %s", path, self.orm_wrapper.layer_version_objects) - + # if we get here, we didn't read layers correctly; + # dump whatever information we have on the error log + logger.warning("Could not match layer dependency for path %s : %s", + pathRE, + self.orm_wrapper.layer_version_objects) def _get_layer_version_for_path(self, path): self._ensure_build() -- 2.7.4