Commit d8de20ab authored by Jens Kroeger's avatar Jens Kroeger
Browse files

jobsub + Colourer: handle difference between str and byte string in python3

parent 3310fbfd
......@@ -90,7 +90,11 @@ def add_coloring_to_emit_ansi(fn):
color = '\x1b[35m' # pink
else:
color = '\x1b[0m' # normal
if type(args[1].msg) == str:
args[1].msg = color + args[1].msg + '\x1b[0m' # normal
else:
args[1].msg = color + (args[1].msg).decode('utf-8') + '\x1b[0m' # normal
#print "after"
return fn(*args)
return new
......
......@@ -265,22 +265,22 @@ def runCorryvreckan(filenamebase, jobtask, silent):
try:
line = qout.get_nowait() # or q.get(timeout=.1)
if not silent:
if "WARNING" in line.strip():
if 'WARNING'.encode() in line.strip():
log.warning(line.strip())
elif "ERROR" in line.strip():
elif b'ERROR' in line.strip():
log.error(line.strip())
elif "FATAL" in line.strip():
elif b'FATAL' in line.strip():
log.critical(line.strip())
else:
log.info(line.strip())
log_file.write(line)
log_file.write(str(line,'utf-8'))
except Empty:
pass
try:
line = qerr.get_nowait() # or q.get(timeout=.1)
log.error(line.strip())
log_file.write(line)
log_file.write(str(line,'utf-8'))
except Empty:
sleep(0.005) # sleep for 5 ms to avoid excessive CPU load
......@@ -301,14 +301,14 @@ def runCorryvreckan(filenamebase, jobtask, silent):
log.critical(line.strip())
else:
log.info(line.strip())
log_file.write(line)
log_file.write(str(line,'utf-8'))
except Empty:
pass
try:
line = qerr.get_nowait() # or q.get(timeout=.1)
log.error(line.strip())
log_file.write(line)
log_file.write(str(line,'utf-8'))
except Empty:
pass
finally:
......
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