From patchwork Thu Oct 31 13:42:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1187475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GtrSKYBX"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 473mn562Spz9sP6 for ; Fri, 1 Nov 2019 00:46:01 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 6F6E6C21F31; Thu, 31 Oct 2019 13:44:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 27988C21F41; Thu, 31 Oct 2019 13:43:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BA2F7C21EDE; Thu, 31 Oct 2019 13:43:36 +0000 (UTC) Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by lists.denx.de (Postfix) with ESMTPS id 0E4DEC21EBE for ; Thu, 31 Oct 2019 13:43:34 +0000 (UTC) Received: by mail-il1-f172.google.com with SMTP id i12so5410351ils.6 for ; Thu, 31 Oct 2019 06:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aju0cJW8DjgveHYiUY/izJmrPptMz7OF+fCBSSxsbbo=; b=GtrSKYBX/R7tRCqmlrVw7jvu3fWbiT+EkDYaLCfVmvavgI4Tg58kG6lVn0NY75ds0E Xz6d1rsbIhjZBj/yiANeG564a/qo2JJ+677FVQvbOxH9pGE58GgrXL77LHo/Xu4J4vMG NG+OLfj7OXz3yJsZ6IR7vGuC3IRFQ/E+w5moo= 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=aju0cJW8DjgveHYiUY/izJmrPptMz7OF+fCBSSxsbbo=; b=nm3drLMihVenuk7/RgeqTxWLDbhb+9giBLwmXwyj6of9dtHvvEi/pU/T4LjqVmleCF uFz3sghWv3Ws5Df6KX2f8dNzbaG3UeTze72+eDRmo4NRKyUO4tXX8+1jqlrwY3+VID9y QeJZ9t/zMOUZm2PRLvaZNKdHAsP2gUHggb3xotI3ommx790w+8CO97QosmCTkZXygPGr eAX8Xkh2eOb6FTcydTLIlvjP38+A3Yy2rGQLclH56xJsOGgLKrhab733NVJU3B2n0gG3 rWixAopTNj0OYDEK0JF8GWrdps5GNnI9F5D4jLaAfhqseUhMK+2LfBj+/zhi+wwvf5Lo gKAA== X-Gm-Message-State: APjAAAXpDdO6wvC2PlazDvdAQjQVWSuBuUie19od4C/jEb26qWxn9Lir DZh9G2FnIbjIhbniUB2nLiaJAUt37860FA== X-Google-Smtp-Source: APXvYqzOHaFrjjDVaFpXrNi28wrkmrXiv4f36NcTBd6d55k1B+EvUFSn28gMFdivecjekA0IteG6Ug== X-Received: by 2002:a92:865c:: with SMTP id g89mr6504266ild.291.1572529412766; Thu, 31 Oct 2019 06:43:32 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id s70sm539612ili.13.2019.10.31.06.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 06:43:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 31 Oct 2019 07:42:56 -0600 Message-Id: <20191031134310.3072-7-sjg@chromium.org> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog In-Reply-To: <20191031134310.3072-1-sjg@chromium.org> References: <20191031134310.3072-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Tom Rini Subject: [U-Boot] [PATCH v2 07/17] microcode_tool: Convert to Python 3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Convert this tool to Python 3 and make it use that, to meet the 2020 deadline. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: None tools/microcode-tool.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/microcode-tool.py b/tools/microcode-tool.py index 249a33b8ca..24c02c4fca 100755 --- a/tools/microcode-tool.py +++ b/tools/microcode-tool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0+ # # Copyright (c) 2014 Google, Inc @@ -126,15 +126,15 @@ def List(date, microcodes, model): microcodes: Dict of Microcode objects indexed by name model: Model string to search for, or None """ - print 'Date: %s' % date + print('Date: %s' % date) if model: mcode_list, tried = FindMicrocode(microcodes, model.lower()) - print 'Matching models %s:' % (', '.join(tried)) + print('Matching models %s:' % (', '.join(tried))) else: - print 'All models:' - mcode_list = [microcodes[m] for m in microcodes.keys()] + print('All models:') + mcode_list = [microcodes[m] for m in list(microcodes.keys())] for mcode in mcode_list: - print '%-20s: model %s' % (mcode.name, mcode.model) + print('%-20s: model %s' % (mcode.name, mcode.model)) def FindMicrocode(microcodes, model): """Find all the microcode chunks which match the given model. @@ -164,7 +164,7 @@ def FindMicrocode(microcodes, model): for i in range(3): abbrev = model[:-i] if i else model tried.append(abbrev) - for mcode in microcodes.values(): + for mcode in list(microcodes.values()): if mcode.model.startswith(abbrev): found.append(mcode) if found: @@ -229,17 +229,17 @@ data = <%s args += [mcode.words[i] for i in range(7)] args.append(words) if outfile == '-': - print out % tuple(args) + print(out % tuple(args)) else: if not outfile: if not os.path.exists(MICROCODE_DIR): - print >> sys.stderr, "Creating directory '%s'" % MICROCODE_DIR + print("Creating directory '%s'" % MICROCODE_DIR, file=sys.stderr) os.makedirs(MICROCODE_DIR) outfile = os.path.join(MICROCODE_DIR, mcode.name + '.dtsi') - print >> sys.stderr, "Writing microcode for '%s' to '%s'" % ( - ', '.join([mcode.name for mcode in mcodes]), outfile) + print("Writing microcode for '%s' to '%s'" % ( + ', '.join([mcode.name for mcode in mcodes]), outfile), file=sys.stderr) with open(outfile, 'w') as fd: - print >> fd, out % tuple(args) + print(out % tuple(args), file=fd) def MicrocodeTool(): """Run the microcode tool""" @@ -289,14 +289,14 @@ def MicrocodeTool(): if cmd == 'list': List(date, microcodes, options.model) elif cmd == 'license': - print '\n'.join(license_text) + print('\n'.join(license_text)) elif cmd == 'create': if not options.model: parser.error('You must specify a model to create') model = options.model.lower() if options.model == 'all': options.multiple = True - mcode_list = microcodes.values() + mcode_list = list(microcodes.values()) tried = [] else: mcode_list, tried = FindMicrocode(microcodes, model)