From patchwork Wed Feb 25 21:17:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Erdmann?= X-Patchwork-Id: 443669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 986E3140083 for ; Thu, 26 Feb 2015 08:26:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="verification failed; unprotected key" header.d=mailerd.de header.i=@mailerd.de header.b=fj0GZIgn; dkim-adsp=none (unprotected policy); dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id C36D532C1E; Wed, 25 Feb 2015 21:26:00 +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 gE2m9dHtLTn2; Wed, 25 Feb 2015 21:25:59 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 691BD32EAE; Wed, 25 Feb 2015 21:25:59 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id AFED51C2214 for ; Wed, 25 Feb 2015 21:25:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id AAA7BA2230 for ; Wed, 25 Feb 2015 21:25:56 +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 q9bESer0Hnzn for ; Wed, 25 Feb 2015 21:25:55 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 348D6A2138 for ; Wed, 25 Feb 2015 21:25:55 +0000 (UTC) Received: by wesu56 with SMTP id u56so6261227wes.10 for ; Wed, 25 Feb 2015 13:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailerd.de; s=mails; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=feVbobk04HopB8FTshQGs2ZRZ8yRzMO69+EzRpRkXtg=; b=fj0GZIgnLq7kP6bb6AnmnDXI3kVSFHiYZQpzTNHqx1OgfqZmXE3zUKwwDihyPIOmvE IHpZsf530ARPtfpqG+2HA8wCUrR3mFZy2j4e8YGqLQQP6vwh9vdf6kzXW0W24Vhc2X+W Sm5W5qcwgjOUKW9fjHRLNXwJLJxhMxgrBMMyE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type :content-transfer-encoding; bh=feVbobk04HopB8FTshQGs2ZRZ8yRzMO69+EzRpRkXtg=; b=ZdwNNm8/LbpW663eRLnjGgZbwj6uXJFAkBAPK9IIn6i2FAu5M57653PxOnLZhEUmil oB/YXaDeYtZbv3FYj2Z0nmGX88XVjmmtsbLyEX9K3CGfJEEZiYRJob12Ry4s9d2IEy3c QNfe2oE5i/Wxv6WRq9kgl/qeL7KXSoyVN7OwJLlYnaJ3APkxE2x5x7+0NtVq1G5vv6DR wWDldP+UbgiI6vDAbIMozLLbQ8HSd2kXuUw8wzFHNXVc09naXoJlbS5KUucUEC2vIS5Z nbIswbUJ/8sL0fUswF/HGzaELVw2jeuWTeRo2SBElN2NOSHaxmSc8RluY/NbSl4BMaSa gVbw== X-Gm-Message-State: ALoCoQkNHyOyq/eOR84bM2Hg3mvDniMewiqA/YENq5cJMZ2pcixc/30t9ZknHEXT6illx7YciBD4 X-Received: by 10.180.103.102 with SMTP id fv6mr9899012wib.80.1424899067670; Wed, 25 Feb 2015 13:17:47 -0800 (PST) Received: from localhost.localdomain (dslb-188-105-009-107.188.105.pools.vodafone-ip.de. [188.105.9.107]) by mx.google.com with ESMTPSA id fo9sm26800926wib.16.2015.02.25.13.17.45 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 13:17:46 -0800 (PST) From: =?UTF-8?q?Andr=C3=A9=20Erdmann?= To: buildroot@buildroot.org Date: Wed, 25 Feb 2015 22:17:20 +0100 Message-Id: <1424899050-24932-4-git-send-email-dywi@mailerd.de> X-Mailer: git-send-email 2.3.0 In-Reply-To: <1424899050-24932-1-git-send-email-dywi@mailerd.de> References: <1424899050-24932-1-git-send-email-dywi@mailerd.de> MIME-Version: 1.0 Cc: thomas.petazzoni@free-electrons.com Subject: [Buildroot] [PATCH 03/13] autobuild-run, python3: bytes<>str, decode() X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" urlopen.read[lines]() returns bytes in py3 and text in py2. Decode the bytes if necessary. Py2k compatibility: no-op decode_bytes(), decode_byte_list() functions Note: The Py2k variant of the decode_byte_list() function returns the input list, whereas the python3 variant creates a new list. Note2: This commit does not add encode() functions, which could be necessary when writing non-ascii chars to files -- in Python3 only. Signed-off-by: André Erdmann --- scripts/autobuild-run | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/autobuild-run b/scripts/autobuild-run index be2f482..3a3b8de 100755 --- a/scripts/autobuild-run +++ b/scripts/autobuild-run @@ -79,6 +79,19 @@ else: urlopen = _urllib.urlopen +if sys.hexversion >= 0x3000000: + def decode_bytes(b): + return b.decode() + + def decode_byte_list(bl): + return [b.decode() for b in bl] +else: + def _identity(e): + return e + + decode_bytes = _identity + decode_byte_list = _identity + MAX_DURATION = 60 * 60 * 4 VERSION = 1 @@ -88,7 +101,7 @@ def log_write(logf, msg): def check_version(): r = urlopen('http://autobuild.buildroot.org/version') - version = int(r.readline().strip()) + version = int(decode_bytes(r.readline()).strip()) if version > VERSION: print("ERROR: script version too old, please upgrade.") sys.exit(1) @@ -143,7 +156,7 @@ def get_toolchain_configs(): """ r = urlopen('http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv') - l = r.readlines() + l = decode_byte_list(r.readlines()) configs = [] for row in csv.reader(l): config = {} @@ -158,7 +171,7 @@ def get_toolchain_configs(): continue config["libc"] = row[2] r = urlopen(config["url"]) - config["contents"] = r.readlines() + config["contents"] = decode_byte_list(r.readlines()) configs.append(config) return configs