mirror of https://github.com/CGAL/cgal
WIP: handle the gzip compression and base64 encoding
This commit is contained in:
parent
a85c1f0ac4
commit
8852f65bc3
|
|
@ -5,19 +5,26 @@ import os
|
|||
import errno
|
||||
import re
|
||||
import sys
|
||||
import base64
|
||||
import zlib
|
||||
import gzip
|
||||
|
||||
result_file_name='{dir}/results_{tester}_{platform}.txt'
|
||||
test_report_filename='{dir}/TestReport_{tester}_{platform}'
|
||||
result_info_file_name='{dir}/results_{tester}_{platform}.info'
|
||||
test_report_filename='{dir}/TestReport_{tester}_{platform}.gz'
|
||||
|
||||
xml = open("Test.xml", 'rb').read();
|
||||
xml = open("Test.xml", 'rb').read()
|
||||
|
||||
def open_file_create_dir(filename, mode):
|
||||
def open_file_create_dir(filename, mode, *args, **kwargs):
|
||||
if not os.path.exists(os.path.dirname(filename)):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(filename))
|
||||
except OSError as exc: # Guard against race condition
|
||||
if exc.errno != errno.EEXIST:
|
||||
raise
|
||||
if kwargs.get('gzip', None) == True:
|
||||
return gzip.open(filename, mode)
|
||||
else:
|
||||
return open(filename, mode)
|
||||
|
||||
root=ET.fromstring(xml)
|
||||
|
|
@ -34,11 +41,18 @@ labels = set()
|
|||
tester_name=sys.argv[1]
|
||||
platform_name=sys.argv[2]
|
||||
for t in testing.findall('Test'):
|
||||
t_output = t.find('Results').find('Measurement').find('Value')
|
||||
t_output_value = t_output.text
|
||||
if t_output_value != None:
|
||||
if 'encoding' in t_output.attrib and t_output.attrib['encoding'] == 'base64':
|
||||
t_output_value = base64.standard_b64decode(t_output_value)
|
||||
if 'compression' in t_output.attrib and t_output.attrib['compression'] == 'gzip':
|
||||
t_output_value = zlib.decompress(t_output_value).decode("utf-8")
|
||||
tests[tests_ids[t.find('FullName').text]] = \
|
||||
{ \
|
||||
"Name": t.find('Name').text, \
|
||||
"Status": t.attrib['Status'], \
|
||||
"Output": t.find('Results').find('Measurement').find('Value').text, \
|
||||
"Output": t_output_value, \
|
||||
"Labels": [l.text for l in t.find('Labels').findall('Label')] if t.find('Labels') is not None else ['UNKNOWN_LABEL'], \
|
||||
}
|
||||
|
||||
|
|
@ -59,8 +73,8 @@ with open_file_create_dir(result_file_name.format(dir=os.getcwd(),
|
|||
print(" {} {}".format("successful " if (t['Status'] == 'passed') else "ERROR: ", t['Name']), file=error)
|
||||
if t['Status'] != 'passed':
|
||||
result_for_label='n'
|
||||
elif t['Output'] != None and re.match(r'(^|[^a-zA-Z_,:-])warning', t['Output']):
|
||||
result_for_label='y'
|
||||
elif t['Output'] != None and re.search(r'(^|[^a-zA-Z_,:-])warning', t['Output'], flags=re.IGNORECASE):
|
||||
result_for_label='w'
|
||||
|
||||
with open("{}/ProgramOutput.{}".format(label, t['Name']), 'w') as f:
|
||||
f.write(t['Output'] if t['Output'] != None else "")
|
||||
|
|
|
|||
Loading…
Reference in New Issue