From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Wainer dos Santos Moschetta <wainersm@redhat.com>, qemu-devel@nongnu.org
Cc: fam@euphon.net, alex.bennee@linaro.org, berrange@redhat.com,
lersek@redhat.com, pbonzini@redhat.com, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 2/5] tests/vm: Port basevm to Python 3
Date: Mon, 1 Apr 2019 13:34:17 +0200 [thread overview]
Message-ID: <0e047167-9cc9-d837-e3a0-260a660edd1a@redhat.com> (raw)
In-Reply-To: <20190329210804.22121-3-wainersm@redhat.com>
On 3/29/19 10:08 PM, Wainer dos Santos Moschetta wrote:
> 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 <wainersm@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> tests/vm/basevm.py | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 0556bdcf9e..083befce9f 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
>
>
next parent reply other threads:[~2019-04-01 11:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190329210804.22121-1-wainersm@redhat.com>
[not found] ` <20190329210804.22121-3-wainersm@redhat.com>
2019-04-01 11:34 ` Philippe Mathieu-Daudé [this message]
2019-04-23 19:28 ` [Qemu-devel] [PATCH 0/5] tests/vm: Python 3, improve image caching, and misc Wainer dos Santos Moschetta
2019-04-23 19:28 ` Wainer dos Santos Moschetta
2019-04-24 9:07 ` Laszlo Ersek
2019-04-24 9:07 ` Laszlo Ersek
2019-04-25 18:02 ` Wainer dos Santos Moschetta
2019-04-25 18:02 ` Wainer dos Santos Moschetta
2019-05-29 16:50 ` Alex Bennée
[not found] ` <20190329210804.22121-4-wainersm@redhat.com>
2019-05-29 19:05 ` [Qemu-devel] [PATCH 3/5] tests/vm: Detect the image changed on server Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e047167-9cc9-d837-e3a0-260a660edd1a@redhat.com \
--to=philmd@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=berrange@redhat.com \
--cc=fam@euphon.net \
--cc=lersek@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wainersm@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).