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 <al.bailey@windriver.com>
Change-Id: I94800fa870f1a444df6e95ba2f206803a4acfc18
This commit is contained in:
Al Bailey 2022-05-20 19:13:32 +00:00
parent 985739f7fb
commit 3e6c2d41e1
1 changed files with 8 additions and 1 deletions

View File

@ -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