From 3e6c2d41e199d6f78ed10d6b8724dbbe3dbc0f18 Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Fri, 20 May 2022 19:13:32 +0000 Subject: [PATCH] Debian: Fix sw-manager commands sw-manager strategy creation commands trigger a python3 error. The issue is that python2 supports a string, but python3 expects bytes. The fix is to send the appropriate message based on the whether we are in python2 or python3. Test Plan: Debian: verify sw-manager patch-strategy create works Centos: verify sw-manager patch-strategy create works Closes-Bug: 1974475 Signed-off-by: Al Bailey Change-Id: I94800fa870f1a444df6e95ba2f206803a4acfc18 --- nfv/nfv-common/nfv_common/schedule/_schedule_module.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/nfv/nfv-common/nfv_common/schedule/_schedule_module.py b/nfv/nfv-common/nfv_common/schedule/_schedule_module.py index cbc45e47..29401fd9 100755 --- a/nfv/nfv-common/nfv_common/schedule/_schedule_module.py +++ b/nfv/nfv-common/nfv_common/schedule/_schedule_module.py @@ -3,6 +3,7 @@ # # SPDX-License-Identifier: Apache-2.0 # +import six import socket from nfv_common import selobj @@ -13,6 +14,12 @@ _send_socket = None _receive_socket = None _pending_function_calls = list() +if six.PY3: + # python3 requires the string be converted to bytes + MESSAGE_ONE = '1'.encode('utf-8') +else: + MESSAGE_ONE = '1' + def schedule_function_call(func, *args, **kwargs): """ @@ -22,7 +29,7 @@ def schedule_function_call(func, *args, **kwargs): function_data = (func, args, kwargs) _pending_function_calls.append(function_data) - _send_socket.send('1') + _send_socket.send(MESSAGE_ONE) @coroutine