diff options
author | Arthur Martella <arthur.martella.1@att.com> | 2020-01-29 11:35:34 -0500 |
---|---|---|
committer | Arthur Martella <arthur.martella.1@att.com> | 2020-01-31 14:59:15 -0500 |
commit | a89a4014895a67eadef2a4091c78506117fc2de5 (patch) | |
tree | 5c7fa307fe0f44fc54b34bf47d03a83e1a89f5ea /engine/src/tools | |
parent | 0a81d20a553e3c4ee133136f8d3c07eeb6d8b3b6 (diff) |
Bugfixes for Python 3 conversion
Issue-ID: OPTFRA-646
Signed-off-by: Martella, Arthur <arthur.martella.1@att.com>
Change-Id: Icd9838a54fe13004a94eafbd1d9d1ffc5a5686a6
Diffstat (limited to 'engine/src/tools')
-rw-r--r-- | engine/src/tools/crim.py | 18 | ||||
-rw-r--r-- | engine/src/tools/lib/common.py | 10 | ||||
-rw-r--r-- | engine/src/tools/lib/song.py | 6 | ||||
-rw-r--r-- | engine/src/tools/lib/tables.py | 12 | ||||
-rw-r--r-- | engine/src/tools/lock.py | 2 | ||||
-rw-r--r-- | engine/src/tools/ppdb.py | 8 |
6 files changed, 28 insertions, 28 deletions
diff --git a/engine/src/tools/crim.py b/engine/src/tools/crim.py index a92ac6c..b0a5596 100644 --- a/engine/src/tools/crim.py +++ b/engine/src/tools/crim.py @@ -16,7 +16,7 @@ # # ------------------------------------------------------------------------- # -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 """ Commandline Rest Interface Music (CRIM) @@ -105,13 +105,13 @@ if __name__ == "__main__": if opts.viewTables: for table in Tables.__subclasses__(): - print (re.sub("[[\]',]", '', str(table.table_alias()))).split(" ")[0] + print((re.sub("[[\]',]", '', str(table.table_alias()))).split(" ")[0]) sys.exit(0) if opts.viewSchema: for table in Tables.__subclasses__(): sys.stdout.write(re.sub("[[\]',]", '', str(table.table_alias())) + ' ') - print json.dumps(table.schema, sort_keys=True, indent=2), "\n" + print(json.dumps(table.schema, sort_keys=True, indent=2), "\n") sys.exit(0) """ Keyspace Create """ # <<<1 @@ -137,7 +137,7 @@ if __name__ == "__main__": opts.names = True for keyspace in Song.Keyspaces.keys(): music.keyspace = Song.Keyspaces[keyspace] - print "\n----------------- %s : %s -----------------" % (keyspace, music.keyspace) + print("\n----------------- %s : %s -----------------" % (keyspace, music.keyspace)) # noinspection PyBroadException try: for tName in opts.read: @@ -155,13 +155,13 @@ if __name__ == "__main__": # show all db stuff <<<1 if opts.show or opts.ShowConfig: if opts.show: - print "music" + print("music") pprint(music.__dict__, indent=2) - print "\nrest" + print("\nrest") pprint(music.rest.__dict__, indent=2) if table is not None: - print "\n", table.table() + print("\n", table.table()) pprint(table.__dict__, indent=2) if opts.ShowConfig: @@ -193,7 +193,7 @@ if __name__ == "__main__": """ UPDATE use json file to update db record """ # <<<1 if opts.action == 'u': if not opts.file or not os.path.exists(opts.file): - print "--file filename (filename exists) is required for update" + print("--file filename (filename exists) is required for update") sys.exit(1) table.update(opts.file) @@ -202,7 +202,7 @@ if __name__ == "__main__": """ DELETE use id to delete record from db -- requres ID """ # <<<1 if opts.action == 'd': if not opts.id: - print "--id ID is required for delete" + print("--id ID is required for delete") sys.exit(1) if opts.id: diff --git a/engine/src/tools/lib/common.py b/engine/src/tools/lib/common.py index 4973f4e..643e988 100644 --- a/engine/src/tools/lib/common.py +++ b/engine/src/tools/lib/common.py @@ -37,7 +37,7 @@ def set_argument(arg=None, prompt=None, multiline=False): if sys.stdin in select.select([sys.stdin], [], [], .5)[0]: message = sys.stdin.readlines() else: - print prompt, + print(prompt) if multiline: sentinel = '' message = list(iter(raw_input, sentinel)) @@ -64,10 +64,10 @@ if __name__ == "__main__": msg = set_argument(sys.argv[0]) for row in msg: - print row, - print "\n", list2string(msg) + print(row) + print("\n", list2string(msg)) msg = set_argument(prompt="Message? ") for row in msg: - print row, - print "\n", list2string(msg) + print(row) + print("\n", list2string(msg)) diff --git a/engine/src/tools/lib/song.py b/engine/src/tools/lib/song.py index fdbba99..8383ffe 100644 --- a/engine/src/tools/lib/song.py +++ b/engine/src/tools/lib/song.py @@ -44,7 +44,7 @@ def hosts(opts, config): config["music"]["hosts"] = _hosts["music"][opts.env or "dev"]["hosts"]["a"] if opts.verbose: - print "hosts: " + str(config["music"]["hosts"]) + print("hosts: " + str(config["music"]["hosts"])) # noinspection PyBroadException @@ -61,7 +61,7 @@ class Song(Music): "ist": "valet_IST", "gj": "valet_TestDB2" } - Keyspaces.update(dict((v, v) for k, v in Keyspaces.iteritems())) # full name is valid too + Keyspaces.update(dict((v, v) for k, v in Keyspaces.items())) # full name is valid too def __init__(self, opts, config, logger): if opts.env: @@ -143,7 +143,7 @@ def main(): config = json.loads(open(opts.config).read()) music = Song(opts, config, logger) - print json.dumps(config.get("music")) + print (json.dumps(config.get("music"))) print (music.keyspace) diff --git a/engine/src/tools/lib/tables.py b/engine/src/tools/lib/tables.py index 7ad4836..b0957a4 100644 --- a/engine/src/tools/lib/tables.py +++ b/engine/src/tools/lib/tables.py @@ -94,7 +94,7 @@ class Tables(object): result = self.music.read_row(self.keyspace, self.table(), key, row_id)["result"] # strip "Row n" - for _, data in sorted(result.iteritems()): + for _, data in sorted(result.items()): rows.append(data) if raw: @@ -113,9 +113,9 @@ class Tables(object): if raw: if names: - print "\n" + self.table() + print("\n" + self.table()) for row in rows: - print row + print(row) return if isinstance(rows, list): @@ -142,8 +142,8 @@ class Tables(object): if json_file is None: if names: - print "\n" + self.table() - print json.dumps(rows, sort_keys=True, indent=4) + print("\n" + self.table()) + print (json.dumps(rows, sort_keys=True, indent=4)) return fh = open(json_file, "w") @@ -305,4 +305,4 @@ class Groups(Tables): if __name__ == "__main__": - print Tables.option_choices() + print(Tables.option_choices()) diff --git a/engine/src/tools/lock.py b/engine/src/tools/lock.py index a77eb8a..c9e0cc9 100644 --- a/engine/src/tools/lock.py +++ b/engine/src/tools/lock.py @@ -16,7 +16,7 @@ # # ------------------------------------------------------------------------- # -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import argparse diff --git a/engine/src/tools/ppdb.py b/engine/src/tools/ppdb.py index c89f0f2..93f3b9d 100644 --- a/engine/src/tools/ppdb.py +++ b/engine/src/tools/ppdb.py @@ -16,7 +16,7 @@ # # ------------------------------------------------------------------------- # -#!/usr/bin/env python2.7 +#!/usr/bin/env python3 import sys @@ -39,7 +39,7 @@ if __name__ == "__main__": results = json.loads(inf.read()) if opts.verbose: print (json.dumps(results, sort_keys=True, indent=4)) - print "---------------------------------------------" + print ("---------------------------------------------") if "request" in results.keys(): key = "request" @@ -57,7 +57,7 @@ if __name__ == "__main__": print (json.dumps(result, sort_keys=True, indent=4)) sys.exit(0) - for _, row in result.iteritems(): + for _, row in result.items(): rr = json.loads(row["result"]) # for k, d in row.iteritems(): @@ -65,7 +65,7 @@ if __name__ == "__main__": sys.stdout.write("result ") sys.stdout.flush() - print json.dumps(rr, indent=4) + print (json.dumps(rr, indent=4)) # for f in rr: # for line in (json.dumps(f, sort_keys=True, indent=4)).splitlines(): # print "\t%s"%line |