diff options
author | Neil Williams <codehelp@debian.org> | 2014-06-23 22:36:19 +0100 |
---|---|---|
committer | Senthil Kumaran Shanmugasundaram <senthil.kumaran@linaro.org> | 2017-08-29 14:14:10 +0000 |
commit | a4cfb1b90f15f62c012e594a7e1304d5df841eb7 (patch) | |
tree | c07fe260fb4927f2accd975d4fbbba4bf585ca81 | |
parent | 05d119426f53bcd941e5bac37fe963a07440b5d5 (diff) |
Allow status.py to be run with either version, output which
one is used.
Change-Id: Ifb1ee6b8b6a3b7697c3aaf0f8997d17d02243bff
Reviewed-on: https://review.linaro.org/21061
Reviewed-by: Senthil Kumaran Shanmugasundaram <senthil.kumaran@linaro.org>
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | ci-run | 2 | ||||
-rw-r--r-- | lava-coordinator | 4 | ||||
-rw-r--r-- | lava/__init__.py | 2 | ||||
-rw-r--r-- | lava/coordinator.py | 6 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rwxr-xr-x | status.py | 16 | ||||
-rw-r--r-- | tests/testpoller.py | 2 |
8 files changed, 20 insertions, 16 deletions
@@ -2,3 +2,5 @@ *.egg lava_coordinator.egg-info/ dist/ +.eric6project/ +*.e4p @@ -1,4 +1,4 @@ #!/bin/sh set -e -PYTHONPATH=. python tests/testpoller.py +PYTHONPATH=. python3 tests/testpoller.py diff --git a/lava-coordinator b/lava-coordinator index 23b8de9..b7c558b 100644 --- a/lava-coordinator +++ b/lava-coordinator @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/python3 # Copyright 2013 Linaro Limited # Author Neil Williams <neil.williams@linaro.org> @@ -88,7 +88,7 @@ if __name__ == '__main__': if os.path.exists(os.path.dirname(options.logfile)): logfile = options.logfile else: - print "No such directory for specified logfile '%s'" % logfile + print("No such directory for specified logfile '%s'" % logfile) open(logfile, 'w').close() level = logging.INFO if options.loglevel == "DEBUG": diff --git a/lava/__init__.py b/lava/__init__.py index 39fe225..eb21f7d 100644 --- a/lava/__init__.py +++ b/lava/__init__.py @@ -1 +1 @@ -import coordinator +from . import coordinator diff --git a/lava/coordinator.py b/lava/coordinator.py index 36461b1..8cb81d0 100644 --- a/lava/coordinator.py +++ b/lava/coordinator.py @@ -70,7 +70,7 @@ class LavaCoordinator(object): logging.info("Ready to accept new connections") self.conn, addr = s.accept() # read the header to get the size of the message to follow - data = str(self.conn.recv(8)) # 32bit limit + data = self.conn.recv(8).decode('utf-8') # 32bit limit try: count = int(data, 16) except ValueError: @@ -81,7 +81,7 @@ class LavaCoordinator(object): data = '' # get the message itself while c < count: - data += self.conn.recv(self.blocksize) + data += self.conn.recv(self.blocksize).decode('utf-8') c += self.blocksize try: json_data = json.loads(data) @@ -202,7 +202,7 @@ class LavaCoordinator(object): logging.error("Message was too long to send! %d > %d" % (int(msglen, 16), 0xFFFFFFFF)) return None - return msglen, msgstr + return msglen.encode('utf-8'), msgstr.encode('utf-8') def _sendMessage(self, client_name, messageID): """ Sends a message to the currently connected client. @@ -23,7 +23,7 @@ from setuptools import setup, find_packages setup( name='lava-coordinator', - version="0.1.7", + version="0.1.8", author="Neil Williams", author_email="neil.williams@linaro.org", license="GPL2+", @@ -1,4 +1,4 @@ -#! /usr/bin/python +#! /usr/bin/env python """ Status check for lava-coordinator @@ -44,7 +44,7 @@ def read_settings(filename): "blocksize": 4 * 1024} if not os.path.exists(filename): # unknown as there is no usable configuration - print "No lava-coordinator configuration file found!" + print("No lava-coordinator configuration file found!") sys.exit(3) with open(filename) as stream: jobdata = stream.read() @@ -97,12 +97,12 @@ def lava_poll(port, host, name, request): msg_len = len(msg_str) try: # send the length as 32bit hexadecimal - ret_bytes = sock.send("%08X" % msg_len) + ret_bytes = sock.send(b"%08X" % msg_len) if ret_bytes == 0: warnings.append( "zero bytes sent for length - connection closed?") continue - ret_bytes = sock.send(msg_str) + ret_bytes = sock.send(msg_str.encode('utf-8')) if ret_bytes == 0: warnings.append( "zero bytes sent for message - connection closed?") @@ -118,7 +118,7 @@ def lava_poll(port, host, name, request): errors.append("Exception on receive: %s" % exc) continue try: - json_data = json.loads(data) + json_data = json.loads(data.decode('utf-8')) except ValueError: warnings.append("data not JSON %s" % data) break @@ -137,7 +137,8 @@ def lava_poll(port, host, name, request): elif warnings: ret = 1 if errors or warnings: - print "E:%s W:%s" % (errors, warnings) + print("Using python%s" % sys.version_info[0]) + print("E:%s W:%s" % (errors, warnings)) return ret else: return ret @@ -155,7 +156,8 @@ def main(): ret1 = lava_poll(port, host, 'status', 'group_data') ret2 = lava_poll(port, host, 'status', 'clear_group') if not ret1 and not ret2: - print "status check complete. No errors" + print("Using python%s" % sys.version_info[0]) + print("status check complete. No errors") if ret1 and ret1 >= ret2: sys.exit(ret1) if ret2: diff --git a/tests/testpoller.py b/tests/testpoller.py index f260c69..41f7e7b 100644 --- a/tests/testpoller.py +++ b/tests/testpoller.py @@ -105,7 +105,7 @@ class TestSocket(object): self.log.info("\tCoordinator header: %d bytes" % int(data, 16)) else: try: - json_data = json.loads(data) + json_data = json.loads(data.decode('utf-8')) except ValueError: assert False if not self.response: |