From 3d3c2b186da33b673b970c98824521cd6e0285f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Thu, 4 Jun 2020 10:53:50 +0200 Subject: external: convert scripts to Python3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert scripts to Python3 as Python2 has been EOLed in 2020. Fixes: https://github.com/open-power/skiboot/issues/225 Signed-off-by: Dan HorĂ¡k [Fixed directory walking logic in generate-fwts-olog - Vasant] Signed-off-by: Vasant Hegde --- external/fwts/generate-fwts-olog | 14 ++++++-------- external/fwts/merge-fwts-olog | 22 +++++++++++----------- external/xscom-utils/adu_scoms.py | 2 +- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/external/fwts/generate-fwts-olog b/external/fwts/generate-fwts-olog index c455988..c89fbf6 100755 --- a/external/fwts/generate-fwts-olog +++ b/external/fwts/generate-fwts-olog @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # # Copyright 2016 Jeremy Kerr @@ -31,7 +31,7 @@ def create_parser(): # Match the following prlog() call log_call = (((Literal("prerror") + Literal('(').suppress()) | (Literal("prlog") + Literal('(').suppress() + - Word(string.letters + string.digits + '_') + + Word(string.ascii_letters + string.digits + '_') + Literal(',').suppress())) + Combine(OneOrMore(QuotedString('"')), adjacent=False) + (Literal(')') | Literal(',')).suppress() @@ -63,11 +63,9 @@ def find_sources(dirname): def is_source(fname): return fname.endswith('.c') - def add_fn(s, dname, fnames): - s.extend([ os.path.join(dname, fname) - for fname in fnames if is_source(fname) ]) - - os.path.walk(dirname, add_fn, sources) + for directory, dirnames, filenames in os.walk(dirname): + sources.extend([ os.path.join(directory, fname) + for fname in filenames if is_source(fname) ]) return sources def cleanup_content(content): @@ -212,7 +210,7 @@ if __name__ == '__main__': sources = [] for directory in args.directories: try: - git_tag = subprocess.check_output(["git","-C", directory, "describe", "--abbrev=0" ]) + git_tag = subprocess.check_output(["git","-C", directory, "describe", "--abbrev=0" ], text=True) except: git_tag = "???" git_tag = git_tag.replace("\n", "") diff --git a/external/fwts/merge-fwts-olog b/external/fwts/merge-fwts-olog index 132d898..de70d6c 100755 --- a/external/fwts/merge-fwts-olog +++ b/external/fwts/merge-fwts-olog @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python3 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later # # Copyright 2016 IBM Corp. @@ -14,17 +14,17 @@ json_params = { def get_input(): while True: - resp = raw_input("Update pattern to match both? (y/n): ") + resp = input("Update pattern to match both? (y/n): ") if resp in [ "y", "Y" ]: break elif resp in [ "n", "N" ]: - print "New entry will be added." + print("New entry will be added.") return False else: - print "???" + print("???") continue - return raw_input("New pattern: ") + return input("New pattern: ") def main(): if len(sys.argv) != 4: @@ -69,12 +69,12 @@ def main(): continue if cp["pattern"] != op["pattern"]: - print "Pattern update detected." - print "Label: %s" % cp["label"] - print "" - print "Cur Pattern: %s" % cp["pattern"] - print "New Pattern: %s" % op["pattern"] - print "" + print("Pattern update detected.") + print("Label: %s" % cp["label"]) + print("") + print("Cur Pattern: %s" % cp["pattern"]) + print("New Pattern: %s" % op["pattern"]) + print("") user_pattern = get_input() diff --git a/external/xscom-utils/adu_scoms.py b/external/xscom-utils/adu_scoms.py index cb1c0d2..6273ead 100755 --- a/external/xscom-utils/adu_scoms.py +++ b/external/xscom-utils/adu_scoms.py @@ -164,7 +164,7 @@ class GetSCom(object): c_id = val >> 44 id = c_id & 0xff - if id == 0xef: + if id == 0xef: name = "P8E (Murano) processor" elif id == 0xea: name = "P8 (Venice) processor" -- cgit v1.1