From 81c0adbbe30bff28aab74c7ef188541b0438518d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 28 Jun 2019 08:51:57 -0400 Subject: [PATCH] More python 3 compatibility fixes Improve more commands and modules to parse and execute under python 3. --- confluent_client/bin/nodehealth | 3 ++- confluent_client/bin/nodeinventory | 5 +++-- confluent_server/confluent/main.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/confluent_client/bin/nodehealth b/confluent_client/bin/nodehealth index f758431c..1896c18e 100755 --- a/confluent_client/bin/nodehealth +++ b/confluent_client/bin/nodehealth @@ -32,7 +32,8 @@ if path.startswith('/opt'): import confluent.client as client -sys.stdout = codecs.getwriter('utf8')(sys.stdout) +if sys.version_info[0] < 3: + sys.stdout = codecs.getwriter('utf8')(sys.stdout) argparser = optparse.OptionParser(usage="Usage: %prog ") (options, args) = argparser.parse_args() diff --git a/confluent_client/bin/nodeinventory b/confluent_client/bin/nodeinventory index 95e1c7b0..2be1fe27 100755 --- a/confluent_client/bin/nodeinventory +++ b/confluent_client/bin/nodeinventory @@ -34,7 +34,8 @@ if path.startswith('/opt'): import confluent.client as client -sys.stdout = codecs.getwriter('utf8')(sys.stdout) +if sys.version_info[0] < 3: + sys.stdout = codecs.getwriter('utf8')(sys.stdout) filters = [] @@ -145,7 +146,7 @@ try: databynode[node] = {} databynode[node][prefix] = inv else: - print '{0}: {1}: Not Present'.format(node, prefix) + print('{0}: {1}: Not Present'.format(node, prefix)) continue info = inv['information'] info.pop('board_extra', None) diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 4b904471..67d0db2f 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -237,7 +237,7 @@ def run(): signal.signal(signal.SIGTERM, terminate) collective.startup() if dbgif: - oumask = os.umask(0077) + oumask = os.umask(0o077) try: os.remove('/var/run/confluent/dbg.sock') except OSError: