Commit ded03013 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

fixup! Add support for Python 3

This is another fixup for commit
1c8269b2.

This is not covered by tests since they use a fake_send method.
parent c90ab036
Pipeline #7702 passed with stage
in 0 seconds
...@@ -36,6 +36,7 @@ import time ...@@ -36,6 +36,7 @@ import time
import errno import errno
import psutil import psutil
from operator import itemgetter from operator import itemgetter
from slapos.util import str2bytes
def parseArgument(): def parseArgument():
""" """
...@@ -168,15 +169,14 @@ class QemuQMPWrapper(object): ...@@ -168,15 +169,14 @@ class QemuQMPWrapper(object):
return response return response
def _send(self, message, retry=0, sleep=0.5): def _send(self, message, retry=0, sleep=0.5):
self.socket.sendall(json.dumps(message)) for i in range(retry + 1):
self.socket.sendall(str2bytes(json.dumps(message)))
response = self._readResponse() response = self._readResponse()
for i in range(0, retry):
if response is not None: if response is not None:
break break
if i < retry:
print("Retrying send command after %s second(s)..." % sleep) print("Retrying send command after %s second(s)..." % sleep)
time.sleep(sleep) time.sleep(sleep)
self.socket.sendall(json.dumps(message))
response = self._readResponse()
return response return response
def _getVMStatus(self): def _getVMStatus(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment