Commit bbf220ac authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

tools/patchwork_gitlab_igt: Strip ANSI escape sequences from job's output

GitLab uses ANSI escape sequences to change colors for the output to
denote errors and such. They don't look well in patchwork or in the
emails that we send out so let's strip them!
Signed-off-by: default avatarArkadiusz Hiler <>
parent f7fab721
......@@ -7,6 +7,7 @@ import time
import sys
import os
import io
import re
from zipfile import ZipFile
from itertools import groupby
......@@ -53,6 +54,8 @@ Thanks in advance!
ESCAPE_RE = re.compile(r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])')
def find_next(pipeline_list, last_processed):
if last_processed < pipeline_list[-1]['id']:
......@@ -116,6 +119,10 @@ def has_failed(x):
return x['status'] == 'failed'
def strip_escape(txt):
return ESCAPE_RE.sub('', txt)
def groupsort(iterable, key=None):
return groupby(sorted(iterable, key=key), key=key)
......@@ -143,7 +150,7 @@ def get_details(pipeline):
log_resp = requests.get(log_url, headers=GITLAB_HEADERS)
last_lines = log_resp.content.decode().splitlines()[-20:]
details += " " + "\n ".join(last_lines)
details += " " + strip_escape("\n ".join(last_lines))
details += "\n"
return details
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