From patchwork Sun Jul 7 05:28:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Lele X-Patchwork-Id: 1128567 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uEiSpjKa"; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45hHG71qd3z9s8m for ; Sun, 7 Jul 2019 15:29:51 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B7E7987108; Sun, 7 Jul 2019 05:29:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id O45NFBRq9U58; Sun, 7 Jul 2019 05:29:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id ED15E87082; Sun, 7 Jul 2019 05:29:48 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id CED5F1BF5DD for ; Sun, 7 Jul 2019 05:29:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id C857184AF4 for ; Sun, 7 Jul 2019 05:29:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8KM7QPfGSDYS for ; Sun, 7 Jul 2019 05:29:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 4165984506 for ; Sun, 7 Jul 2019 05:29:47 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id j2so6006862pfe.6 for ; Sat, 06 Jul 2019 22:29:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jv7WWoFIpG1b6byU6+O93J/WQpVnC24lvDCFz3bL/og=; b=uEiSpjKaw0YF/F+XntmyhI+MydZ7EaXGFxzCnk9cLhDCn0nRFOwT13+hz07e0XNttl Oo4PnoiA1eafguOry79eB7wF6AKdmhddmp92snFhExOXajpGL3/K+OEGJVJOKQVb6qNx Msv+8FQJPFfREgwB5MUFdBraO88A/X0AcrZX6otD7mtH4t33NB4yJ4Msum/aSX4m78D1 Nmr+bIcjk1WzEzFNnWs8CgfbMkxXOSxqTKKiW8QAWKgK4VMflid8XU0KA7u7e+jlOTVw sFB8rJ254PmffWYpU+FwopHf4tL341mGDaOfJCOa/clivlkbjUhtmywroJFxiztYdXxA cEIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jv7WWoFIpG1b6byU6+O93J/WQpVnC24lvDCFz3bL/og=; b=r74T2g8iwfxup6ORoXHYVbsLrwQN5Vj27TUPTsIKMkcx7WOGddzQ/3gjB/DGVYCchV uKkm1So1pWhFlwbRufPM7I+be2po8sXlP0eOYy1/zW9HaTW74hYycxwYKwAOWhpYky0B dsRGlKbeRwvvh9ucgJm4nXkQomTciO0yTxFuz4ZTqK5QpmeUozyCEHVJmSlaM69HmJB/ v6iEhT+U03QJ4S4TCwbiQ4iUV3WSTUnDFPLai+J2efjkFXLJ7tkUDnF9KcxZG4/jFHYk ZIkx7LEyTlnuUKzrtxfAenkX0OwNjkt1wb79QlvxsyZZlESConzq6DQShoeN8OIgj718 mwNg== X-Gm-Message-State: APjAAAXeVNI0gbHViUmDlWBV+EWyv8NtSRp+uP6nWUo14Ibu+SOiWvAI HNX95zWUl4qX4ihzh1kJqP9KLjycpjvcIA== X-Google-Smtp-Source: APXvYqyPcrBRoSJIYLpsF+RmxfGaHB7REIsRJ+oc54bNrBzyXSq2g77qDT2Cs+A1jsLoIiCKD7/T2Q== X-Received: by 2002:a63:b555:: with SMTP id u21mr14691594pgo.222.1562477386378; Sat, 06 Jul 2019 22:29:46 -0700 (PDT) Received: from localhost.localdomain ([123.201.194.71]) by smtp.gmail.com with ESMTPSA id j24sm18039214pgg.86.2019.07.06.22.29.44 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 06 Jul 2019 22:29:45 -0700 (PDT) From: Atharva Lele To: buildroot@buildroot.org Date: Sun, 7 Jul 2019 10:58:22 +0530 Message-Id: <20190707052831.9469-22-itsatharva@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190707052831.9469-1-itsatharva@gmail.com> References: <20190707052831.9469-1-itsatharva@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 22/31] autobuild-run: move get_branch() to Builder class X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Atharva Lele , yann.morin.1998@free.fr, thomas.petazzoni@bootlin.com Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" get_branch() requires http_url and is only called inside Builder class. Moving it to builder class makes http_url available to it and makes the Builder class cohesive. Signed-off-by: Atharva Lele Reviewed-by: Arnout Vandecappelle (Essensium/Mind) --- Changes v1 -> v2: - New patch --- scripts/autobuild-run | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/autobuild-run b/scripts/autobuild-run index 391c1dc..ccfa9c4 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -178,23 +178,6 @@ def log_write(logf, msg): logf.write("[%s] %s\n" % (strftime("%a, %d %b %Y %H:%M:%S", localtime()), msg)) logf.flush() -def get_branch(): - """Returns the branch that should be built. It fetches a CSV file from - autobuild.buildroot.org that provides the list of branches to test - (first field) and their weight (second field). We build a list of - branches, where the branch name is repeated N times, with N being - the weight of the branch. We then pick a random branch in this - list. This way, branches with a higher weight are more likely to - be selected. - """ - with urlopen_closing('http://autobuild.buildroot.org/branches') as r: - csv_branches = r.readlines() - branches = [] - for branch in csv.reader(csv_branches): - branches += [branch[0]] * int(branch[1]) - - return branches[randint(0, len(branches) - 1)] - class SystemInfo: DEFAULT_NEEDED_PROGS = ["make", "git", "gcc"] DEFAULT_OPTIONAL_PROGS = ["bzr", "diffoscope", "java", "javac", "jar"] @@ -306,6 +289,23 @@ class Builder: print("ERROR: script version too old, please upgrade.") sys.exit(1) + def get_branch(self): + """Returns the branch that should be built. It fetches a CSV file from + autobuild.buildroot.org that provides the list of branches to test + (first field) and their weight (second field). We build a list of + branches, where the branch name is repeated N times, with N being + the weight of the branch. We then pick a random branch in this + list. This way, branches with a higher weight are more likely to + be selected. + """ + with urlopen_closing('http://autobuild.buildroot.org/branches') as r: + csv_branches = r.readlines() + branches = [] + for branch in csv.reader(csv_branches): + branches += [branch[0]] * int(branch[1]) + + return branches[randint(0, len(branches) - 1)] + def prepare_build(self): """Prepare for the next build of the specified instance @@ -346,7 +346,7 @@ class Builder: os.path.relpath(f, self.dldir)) os.remove(f) - branch = get_branch() + branch = self.get_branch() log_write(self.log, "INFO: testing branch '%s'" % branch) # Clone Buildroot. This only happens if the source directory