Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id C3A87E00D44; Tue, 22 Nov 2016 09:56:35 -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 * [209.85.192.178 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-pf0-f178.google.com (mail-pf0-f178.google.com [209.85.192.178]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id 235F2E00CD6 for ; Tue, 22 Nov 2016 09:56:17 -0800 (PST) Received: by mail-pf0-f178.google.com with SMTP id 189so5174272pfz.3 for ; Tue, 22 Nov 2016 09:56:17 -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=Y6nDWjDXAuGsg0OBPNKvRcl7+LeGYoTSajDh/lGv9dVgxnlEV12mcxvKBL/wTw2duo rKuNLYC3b/oJ2IgbILSbO2k5NRMJLmZDzCm+vxqhZFTxkGeXQoJuaYJKb6cj0IS8KxKC gH1igyrDvXFNKezzFgXsHOcQ8lDrwqvHsjcC1RRmDpr0rPS/wx8a3ux+QSIn+eLkcu4b A362qH6jwLIOCgDRbYmJUE5VAw0mbKmQ8e9UaUPyOcrQJU911HqLmGScNip+MJtWs8N0 aIYzKiLt4PGRYWa3UCN6HaEU/f26K+Dw1gO+IBI5SVDzueERFJ+hAdNjXbNtnLdb7K31 /Q5g== 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=U7eZmX1Ol2/wMHoKY1sQ0//oXlL0a2/1QnaprDG0HeRROAa/tbYqCgVph156tVJCAf fFBTLeIIlrqYx3/gQJVxKeoqWeBKVapZvrzd34FTVq8+ksPac876UmthojNZVGsjpvQ0 eTLJgHiiwGIyVGozmnqodRmlYk1WWZMjkGK8MkqAGS4XKf9WIVR/5dJd1IalXChozhwm /isWXABVnZYYBY3Kddr2ddKW0oTpdoPrXnWij686Yal+VCyKX/J0bX+lf5IJimSy6tIy y30ykEFHrH/K8rXN3K0jqOtWm0Rt8ZTFqeJKbl27FxKcX6Xd0JcPK/QiVcYekGiVoETe BCAA== X-Gm-Message-State: AKaTC03lyT6cJsbHKi/WOMcuHkugtRiWFhNimbDeBxyS0wH5R+jZPEp2T1mfvD4drVVGifg/ X-Received: by 10.99.103.1 with SMTP id b1mr13674554pgc.58.1479837377518; Tue, 22 Nov 2016 09:56:17 -0800 (PST) Received: from orion.ger.corp.intel.com ([192.55.54.42]) by smtp.gmail.com with ESMTPSA id y6sm28758504pge.27.2016.11.22.09.56.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 22 Nov 2016 09:56:17 -0800 (PST) From: Michael Wood To: toaster@yoctoproject.org Date: Tue, 22 Nov 2016 17:55:37 +0000 Message-Id: <1479837338-15969-18-git-send-email-michael.g.wood@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479837338-15969-1-git-send-email-michael.g.wood@intel.com> References: <1479837338-15969-1-git-send-email-michael.g.wood@intel.com> Subject: [PATCH 17/18] 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: Tue, 22 Nov 2016 17:56:35 -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