From nobody Mon Apr 29 01:04:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509986331555678.0985695731814; Mon, 6 Nov 2017 08:38:51 -0800 (PST) Received: from localhost ([::1]:49098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBkQC-0006aE-Pc for importer@patchew.org; Mon, 06 Nov 2017 11:38:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBkOt-0005Hz-9f for qemu-devel@nongnu.org; Mon, 06 Nov 2017 11:37:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBkOq-0002GD-1O for qemu-devel@nongnu.org; Mon, 06 Nov 2017 11:37:27 -0500 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]:53274) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBkOp-0002Fc-RB for qemu-devel@nongnu.org; Mon, 06 Nov 2017 11:37:23 -0500 Received: by mail-wr0-x242.google.com with SMTP id u40so9159208wrf.10 for ; Mon, 06 Nov 2017 08:37:23 -0800 (PST) Received: from localhost.localdomain ([41.90.179.154]) by smtp.googlemail.com with ESMTPSA id f56sm11546940wra.75.2017.11.06.08.37.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 08:37:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ModZolD4eziqqstDGMTfUqMKgeFTo7OsGYOoXmIIf0E=; b=WemxdZYPfYCj1u13mZxEMm4y9xbYpKNL7CCvtMBVGSSnyXnnakdbevk2U+ndYUgz15 kuR6HaVX7JIUhXXWmEHy0WZEo7MtDpB9aMA/RBgryUiVhswn/uALkPt7/9nKK/vPdtAs c0ciY6mIU0obOnqm7M1DxIKRQoto8hy1G1JCAuHGqEutXUJSpQMc+zCB7//257B4j0tq c6XCOY4D+A38fHbWyupDQH+1Jj9HBcsutdXEVzjFHgLP8Ej5PFyF3IAArKoaYCDSXupW Lj1q/eyJlROFCTxePcR235Rkck0s3AH2g3F6ezzYyKjdMELMYbAOJz5ww/GLOOScjjat Lkcg== 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; bh=ModZolD4eziqqstDGMTfUqMKgeFTo7OsGYOoXmIIf0E=; b=Rmgd4/5L25tKJ8DlvEjR1KY61houBn71AKFY9OPiE5ZVDhENd5Bm4EKyJbzeGbNG3r JndiZ2Cceg++4Tr3dauxvQd/N/XnEj1N7hnPXD82fNAk8pTcSOlwRYUPVu8QU+A+q0nD ZICWJjIoHyZG2u7iz/nglAoHzhvldnQQn23GvW2BefSgd8yPRHgGFBwpztmfsfT7nVBm XFVPSOQ54Aw/S7gRNK9NBQR3z1xVQkwLhrprjEpKdsWlwaHUW7yDTuTO7NYzWKo2508x +iwsO7TSgkq/RJ8OLMjiLWxTzKINE2Fknr7/7+rp+QqvUsrNNICmHAR48QD3U/6iM5Xf xXLg== X-Gm-Message-State: AMCzsaVxSnx17zIyE2yc2q8RhbIR8YZYdgqoL8KMaAwO1oM3jlXrHEdL 2yFsCuFNMRlZj+w+fAN0Uf0= X-Google-Smtp-Source: ABhQp+T4IoQMRlSX0WY0XcU3Nzb1fjsZjVK7XLToyaVM/jxCIwV4RmFr5cvjV/lDk24AR/B7lAa29g== X-Received: by 10.223.132.101 with SMTP id 92mr12779375wrf.85.1509986242218; Mon, 06 Nov 2017 08:37:22 -0800 (PST) From: Joannah Nanjekye To: stefanha@redhat.com Date: Mon, 6 Nov 2017 19:35:55 +0300 Message-Id: <1509986155-4735-1-git-send-email-nanjekyejoannah@gmail.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::242 Subject: [Qemu-devel] [RFC PATCH] remove numpy dependency 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: Joannah Nanjekye , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Users tend to hit an ImportError when running analyze-migration.py due to the numpy dependency. numpy functionality isn't actually used, just binary serialization that the standard library 'struct' module already provides. Removing the dependency allows the script to run out-of-the-box. Signed-off-by: Joannah Nanjekye --- scripts/analyze-migration.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py index 1455387..6175c99 100755 --- a/scripts/analyze-migration.py +++ b/scripts/analyze-migration.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, see . =20 -import numpy as np import json import os import argparse @@ -36,23 +35,29 @@ class MigrationFile(object): self.file =3D open(self.filename, "rb") =20 def read64(self): - return np.asscalar(np.fromfile(self.file, count=3D1, dtype=3D'>i8'= )[0]) + buffer =3D file.read(64) + return struct.unpack('>i16', buffer)[0] =20 def read32(self): - return np.asscalar(np.fromfile(self.file, count=3D1, dtype=3D'>i4'= )[0]) + buffer =3D file.read(32) + return struct.unpack('>i8', buffer)[0] =20 def read16(self): - return np.asscalar(np.fromfile(self.file, count=3D1, dtype=3D'>i2'= )[0]) + buffer =3D file.read(16) + return struct.unpack('>i4', buffer)[0] =20 def read8(self): - return np.asscalar(np.fromfile(self.file, count=3D1, dtype=3D'>i1'= )[0]) + buffer =3D file.read(8) + return struct.unpack('>i2', buffer)[0] =20 def readstr(self, len =3D None): + read_format =3D str(len) + 'd' if len is None: len =3D self.read8() if len =3D=3D 0: return "" - return np.fromfile(self.file, count=3D1, dtype=3D('S%d' % len))[0] + buffer =3D file.read(8) + return struct.unpack(read_format, buffer[0:(0 + struct.calcsize(re= ad_format))]) =20 def readvar(self, size =3D None): if size is None: @@ -303,8 +308,10 @@ class VMSDFieldInt(VMSDFieldGeneric): =20 def read(self): super(VMSDFieldInt, self).read() - self.sdata =3D np.fromstring(self.data, count=3D1, dtype=3D(self.s= dtype))[0] - self.udata =3D np.fromstring(self.data, count=3D1, dtype=3D(self.u= dtype))[0] + buffer =3D file.read(self.data) + read_format =3D self.sdtype + self.sdata =3D struct.unpack(self.sdtype, buffer[0:(0 + struct.cal= csize(self.sdtype))]) + self.sdata =3D struct.unpack(self.udtype, buffer[0:(0 + struct.cal= csize(self.udtype))]) self.data =3D self.sdata return self.data =20 --=20 2.7.4