From patchwork Sun Jul 7 05:28:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atharva Lele X-Patchwork-Id: 1128568 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.136; helo=silver.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="Ldvj62at"; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45hHGC6jtWz9sCJ for ; Sun, 7 Jul 2019 15:29:55 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 59BA220480; Sun, 7 Jul 2019 05:29:54 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UxLE0DNFM1Pr; Sun, 7 Jul 2019 05:29:47 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 42D62203C3; Sun, 7 Jul 2019 05:29:47 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 6FAA91BF5DD for ; Sun, 7 Jul 2019 05:29:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6BFAC87082 for ; Sun, 7 Jul 2019 05:29:45 +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 3lprWkrMiDhk for ; Sun, 7 Jul 2019 05:29:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by hemlock.osuosl.org (Postfix) with ESMTPS id B5BCC8702D for ; Sun, 7 Jul 2019 05:29:44 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id m4so6039833pgk.0 for ; Sat, 06 Jul 2019 22:29:44 -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=o++Q7ln/GUoIHHganxrehuyBNxr07J6LxIzsYLfcSCA=; b=Ldvj62at1c97si/m9Hr5nIebN1aDV4adBbgqLb3yeUsTtZZ6R5b+lWdFi3TTZpBnB0 qv1PP9ibp8g+hr7bdyqZZeZ6f+Ex2YuvDYpmfQ3p/hcP7w7Bgmki9yzHfdZRQmncvOwT diTFM16LywLBCPL3Pxb/yIwYiwBFOGZMej5ypkKysFb+8rqmoO0Ojg+LL75KlRx9/o6/ Kk+mbb20JImSIJPmMApfnevdxkldXcX9DP3sSLCqk1EzFUDjQhk9d9gDPdhVLklf5lCN Ml6w9urBrWOZ/VtaWcLwaTNUQNtjDwnSrgBW7aojUs9pvKWgmAPcaLBayXVycDL0FjFT 9KVQ== 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=o++Q7ln/GUoIHHganxrehuyBNxr07J6LxIzsYLfcSCA=; b=ggSQCOCr0EVlEu+drIGkovK0GVODYaJNPRL2eLGYR1iqVMk1/bvazY5FCuVUn0Kfkw 7eIK0K+No8f7K3K89HkIP/IGcO+NCRn2iy3XTyK1mr61kzBoa8hfECPa1TAbwbpk3V4P UJ9TT02jkgFiWm7hl6az2+B90MCO88dAMIM2+ZZw7Ip1j6Se8o5k1BOlqqjqLwvCvs5Q enq/2MtokshEpxyqfnd5FDuAnYkswmHlU2KoxT94PkwsEyV2Ho6rt57z11/H1T1tnzuE 236AX1pThlJm3d/J9XCa1qtwhejHbYyeiPKyj/WrhMWhoBVQHb+USEk91H85bZhwtPTQ wQfA== X-Gm-Message-State: APjAAAWpd2jQjkpQP97nBzIspw5sayP+iHLGKJTI05RDXe+cGXIeoyee LRhtJTJLg7daZ+3ggS0DmXy+6esdmEBiLw== X-Google-Smtp-Source: APXvYqy7UcCbjf5ROHKrgKm3LtEfGHjvO9JhCZelumr+Mos8TeNDh+9a8ZxXITd3sD+ZVZ6SqGHbQQ== X-Received: by 2002:a17:90a:346c:: with SMTP id o99mr15127622pjb.20.1562477383970; Sat, 06 Jul 2019 22:29:43 -0700 (PDT) Received: from localhost.localdomain ([123.201.194.71]) by smtp.gmail.com with ESMTPSA id j24sm18039214pgg.86.2019.07.06.22.29.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 06 Jul 2019 22:29:43 -0700 (PDT) From: Atharva Lele To: buildroot@buildroot.org Date: Sun, 7 Jul 2019 10:58:21 +0530 Message-Id: <20190707052831.9469-21-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 21/31] autobuild-run: move check_version() 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" Upcoming patch from Thomas needs check_version() to use http_url. As that is inside Builder class and check_version() is only used inside Builder class, move it inside the class. Also remove the redundant call to check_version() from main(). We already call check_version() in run_instance(). Also the fact that we cannot call check_version() in main() since the builder class object is not defined at that point. Signed-off-by: Atharva Lele Reviewed-by: Arnout Vandecappelle (Essensium/Mind) --- Changes v1 -> v2: - New patch --- scripts/autobuild-run | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/autobuild-run b/scripts/autobuild-run index 8a0bec7..391c1dc 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -178,13 +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 check_version(): - with urlopen_closing('http://autobuild.buildroot.org/version') as r: - version = int(decode_bytes(r.readline()).strip()) - if version > VERSION: - print("ERROR: script version too old, please upgrade.") - sys.exit(1) - 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 @@ -306,6 +299,13 @@ class Builder: else: self.log = open(os.path.join(self.idir, "instance.log"), "a+") + def check_version(self): + with urlopen_closing('http://autobuild.buildroot.org/version') as r: + version = int(decode_bytes(r.readline()).strip()) + if version > VERSION: + print("ERROR: script version too old, please upgrade.") + sys.exit(1) + def prepare_build(self): """Prepare for the next build of the specified instance @@ -706,7 +706,7 @@ class Builder: log_write(self.log, "INFO: instance started") while True: - check_version() + self.check_version() ret = self.prepare_build() if ret != 0: @@ -765,7 +765,6 @@ def main(): # showing error messages in another language. os.environ['LC_ALL'] = 'C' - check_version() sysinfo = SystemInfo() args = docopt.docopt(doc, version=VERSION)