Commit 64d4e428 authored by Samuel GAIST's avatar Samuel GAIST Committed by André Anjos
Browse files

[utils][commands][scheduler] Decode message if python is lower than 3.6

Python json module takes only str up to 3.6. Therefore decode
the message received if we are running a python version lower
than 3.6.
parent 5153acb1
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import logging import logging
import signal import signal
import json import json
import sys
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.conf import settings from django.conf import settings
...@@ -142,6 +143,9 @@ class Command(BaseCommand): ...@@ -142,6 +143,9 @@ class Command(BaseCommand):
elif status == BCP.BCPP_JOB_DONE: elif status == BCP.BCPP_JOB_DONE:
output = reply[3] output = reply[3]
if sys.version_info < (3, 6):
output = output.decode("utf-8")
logger.info( logger.info(
"Job split {} was was done by worker {}".format( "Job split {} was was done by worker {}".format(
split_id, worker_id split_id, worker_id
...@@ -170,6 +174,8 @@ class Command(BaseCommand): ...@@ -170,6 +174,8 @@ class Command(BaseCommand):
elif status == BCP.BCPP_JOB_ERROR: elif status == BCP.BCPP_JOB_ERROR:
message = reply[3] message = reply[3]
if sys.version_info < (3, 6):
message = message.decode("utf-8")
logger.info( logger.info(
"Job split {} processed by worker {} failed:\n{}".format( "Job split {} processed by worker {} failed:\n{}".format(
split_id, worker_id, message split_id, worker_id, message
......
Supports Markdown
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