[Skiboot] [PATCH] external: convert scripts to Python3
Dan Horák
dan at danny.cz
Thu Jun 4 18:53:50 AEST 2020
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 <dan at danny.cz>
---
external/fwts/generate-fwts-olog | 8 ++++----
external/fwts/merge-fwts-olog | 22 +++++++++++-----------
external/xscom-utils/adu_scoms.py | 2 +-
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/external/fwts/generate-fwts-olog b/external/fwts/generate-fwts-olog
index c455988de..54fc4fbb3 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 <jk at ozlabs.org>
@@ -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()
@@ -67,7 +67,7 @@ def find_sources(dirname):
s.extend([ os.path.join(dname, fname)
for fname in fnames if is_source(fname) ])
- os.path.walk(dirname, add_fn, sources)
+ os.walk(dirname, add_fn, sources)
return sources
def cleanup_content(content):
@@ -212,7 +212,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 132d8980c..de70d6cfe 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 cb1c0d274..6273eadb1 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"
--
2.21.3
More information about the Skiboot
mailing list