Python3 fixes

Change-Id: I64669dad15ea2c83fec5cf317e7f5c030068b409
(cherry picked from commit b9214c2507)
This commit is contained in:
Sawan Choudhary 2020-07-10 12:03:52 -07:00 committed by Anand Shanmugam
parent 9ec79f7de8
commit 173da89b52
3 changed files with 8 additions and 3 deletions

View File

@ -13,6 +13,8 @@
# limitations under the License. # limitations under the License.
"""Starter script for the Cloudpulse API service.""" """Starter script for the Cloudpulse API service."""
import eventlet
eventlet.monkey_patch()
import logging as std_logging import logging as std_logging
import os import os

View File

@ -57,7 +57,10 @@ class Cpulse(base.CloudpulsePersistentObject, base.CloudpulseObject,
def _from_db_object(test, db): def _from_db_object(test, db):
"""Converts a database entity to a formal object.""" """Converts a database entity to a formal object."""
for field in test.fields: for field in test.fields:
test[field] = db[field] if isinstance(db[field], bytes):
test[field] = db[field].decode('utf-8')
else:
test[field] = db[field]
test.obj_reset_changes() test.obj_reset_changes()
return test return test

View File

@ -98,8 +98,8 @@ def execute(command):
return {'status': 126, 'output': ""} return {'status': 126, 'output': ""}
if p.returncode == 126 or p.returncode == 127: if p.returncode == 126 or p.returncode == 127:
stdout = str(b"") stdout = b''
return {'status': p.returncode, 'output': stdout} return {'status': p.returncode, 'output': stdout.decode('utf-8')}
def get_container_name(name): def get_container_name(name):