From patchwork Thu May 30 10:15:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 165423 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp773649ili; Thu, 30 May 2019 03:26:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgaGknekG0gikT+xOhopGL3CjnlaOSDNxdEwEko7E2PQy9p7mKxcNldp/UDjN5/EsejaT+ X-Received: by 2002:ac8:336a:: with SMTP id u39mr2657194qta.178.1559211973883; Thu, 30 May 2019 03:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559211973; cv=none; d=google.com; s=arc-20160816; b=L4RRLwy+rfXPPXKDPDqOG0EvzqMZmIAdLTbilyHVn0aPVt6bP0SmPuhpE+2/8DFRrq vJqolAzDXBWGZa5sqVTAlh8BA1h9eJ9LuK1TXCBcO1e8Wt8WW240BzXtMrQMAaqRX+nn nOWpRmP7QmORV5+XvMhS01UvVO86h5QSEFM0MzWQnJd2h3kkN4Mj+GgkoPrDCukdevgR GXP+qFIgxtRzzEw66Oz4LZV1Z7D/F9OLwMVC6BfGjjmCJ2wwua/QbkYYn11csf1Tpnjh ve03Aq0j+hjO1epyEs0DTfRpS87HFt4n1JRYEIxtKSGV61q4RGXdfbSuKwDvcno2lSIj h+jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=VBYJNdKck0NWEjbEOdu/UU5WU/f6QnZI7h23fVKWf28=; b=RfiF3QzVR1Buz99c4pyOGK/b0zHrKF+cqC0of3Qnmd9wwFB4/VI5ddwgdC50sXh7SA f1PLfMPUgvUtS7c7gXGsEx8KC4DGEXgrRC7gCnK9NhYmjEPoQl+hPL56mqarLfURdEoe EjyAxKGnQOmq0MlpSxapT2CBfWlkYXJmGKHyjCpXihJqOngjqDTS5p9TBnccvZtHO2sN WLy9ZG7+brIHV0+qQLwnDOEuggf4c/zhIWFOtpgt+dvCdgoGhH9uDHTY780J6HnRMe1V OVkmZCAHOcgBr6bBgD1TOW/TjeUFILyYQdl8Zmskb7jIGpmTunhq02JdUgUzx5Y485Ve B3/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=L+hNcliv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v11si1413659qti.99.2019.05.30.03.26.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 30 May 2019 03:26:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=L+hNcliv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:50689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWIGD-0001rM-Ay for patch@linaro.org; Thu, 30 May 2019 06:26:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hWI6b-0002dd-3r for qemu-devel@nongnu.org; Thu, 30 May 2019 06:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hWI6Z-0006Yz-Ng for qemu-devel@nongnu.org; Thu, 30 May 2019 06:16:16 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:38314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hWI6Z-0006YD-HC for qemu-devel@nongnu.org; Thu, 30 May 2019 06:16:15 -0400 Received: by mail-wm1-x341.google.com with SMTP id t5so3468383wmh.3 for ; Thu, 30 May 2019 03:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VBYJNdKck0NWEjbEOdu/UU5WU/f6QnZI7h23fVKWf28=; b=L+hNclivWdfxNoKP9Bg5hf2z80o79jIPVIg4SR5HEfYzUFc0vWnf2F0ue9qFLldiEr 4yetA3dJhZqKAfepklZYFmo3CBXUB7GQMX779pmL7qUCq2OcCUO96v41Oj9fYvhfh75d Ir5YciGcITLKee7uQfSBYGC7EIQwgO8+gPNoiH9ppdsNdqLHwm2cP4eUeWREWkMAJWux U34GYK2BWqxf3aWSTlkA5QK/wrGRnVncjLDlbe68dv7XghiQVQyUIatFosPGgYWWpspx aDL9dcVlYmOxUJOHm8ASEM1sR6cZHLV8plAYkZ3hksyqP1csrWrUo8SIg8gRDsIWEW/9 ur7w== 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=VBYJNdKck0NWEjbEOdu/UU5WU/f6QnZI7h23fVKWf28=; b=tZ0jFSZj1rZ/8qDXBfFpoC8VSqKi+amoTlpTRY9Ii58J1dp+iiAdrKRiF9rtMeByLi dmfXZYXYEobVO3dzc23trAVKEWlpnsiljkd+0Nl3zwN8zRFoZK1HgZjUbzCK72Ven7kO 0Z0N9GvZEKwqkRYM1Nvd3bOnzoLLOUR3Ivl66UaTGN6kFdXKVdVs77IHpMwP1tTZKcBF gvBOAjxczYiNlmRcz3sbA5fa2TFmNIaBPpfgMNad2nqAnGpTzpK8+uV3Yxc9J78U0Gac nnhD6EoHocXFbyRnfNCZAxsshmX1r4rEkgYAK+Xoji9gQbkuj2f+/aYPgie2voQrvwi1 1YbQ== X-Gm-Message-State: APjAAAUymBS4Reb/jtuk0Nba8+u+cuXGyo9X9moVRbkWFV4mz9EC8ns0 LSH5LUFgQbZ1YxkwYl9BCyBf8A== X-Received: by 2002:a1c:e3d7:: with SMTP id a206mr1840893wmh.7.1559211374442; Thu, 30 May 2019 03:16:14 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id t4sm2364980wmi.41.2019.05.30.03.16.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 30 May 2019 03:16:09 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id D623D1FF9A; Thu, 30 May 2019 11:16:04 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 30 May 2019 11:15:47 +0100 Message-Id: <20190530101603.22254-11-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190530101603.22254-1-alex.bennee@linaro.org> References: <20190530101603.22254-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::341 Subject: [Qemu-devel] [PATCH v1 10/26] tests/vm: Port basevm to Python 3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Wainer dos Santos Moschetta Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Wainer dos Santos Moschetta Fixed tests/vm/basevm.py to run with Python 3: - hashlib.sha1() requires an binary encoded object. - uses floor division ("//") (PEP 238). - decode bytes to unicode when needed. Signed-off-by: Wainer dos Santos Moschetta Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20190329210804.22121-3-wainersm@redhat.com> Signed-off-by: Alex Bennée --- tests/vm/basevm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.20.1 Tested-by: Philippe Mathieu-Daudé diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 0556bdcf9e9..083befce9f5 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -85,12 +85,12 @@ class BaseVM(object): if not sha256sum: return True checksum = subprocess.check_output(["sha256sum", fname]).split()[0] - return sha256sum == checksum + return sha256sum == checksum.decode() cache_dir = os.path.expanduser("~/.cache/qemu-vm/download") if not os.path.exists(cache_dir): os.makedirs(cache_dir) - fname = os.path.join(cache_dir, hashlib.sha1(url).hexdigest()) + fname = os.path.join(cache_dir, hashlib.sha1(url.encode()).hexdigest()) if os.path.exists(fname) and check_sha256sum(fname): return fname logging.debug("Downloading %s to %s...", url, fname) @@ -134,7 +134,7 @@ class BaseVM(object): raise NotImplementedError def add_source_dir(self, src_dir): - name = "data-" + hashlib.sha1(src_dir).hexdigest()[:5] + name = "data-" + hashlib.sha1(src_dir.encode()).hexdigest()[:5] tarfile = os.path.join(self._tmpdir, name + ".tar") logging.debug("Creating archive %s for src_dir dir: %s", tarfile, src_dir) subprocess.check_call(["./scripts/archive-source.sh", tarfile], @@ -204,7 +204,7 @@ def parse_args(vmcls): def get_default_jobs(): if kvm_available(vmcls.arch): - return multiprocessing.cpu_count() / 2 + return multiprocessing.cpu_count() // 2 else: return 1