Commit 4a236935 authored by Łukasz Nowak's avatar Łukasz Nowak

Improve try information formatting

parent c4c881e9
...@@ -87,7 +87,7 @@ def main(): ...@@ -87,7 +87,7 @@ def main():
result_found = False result_found = False
while 1: while 1:
finished = False finished = False
try_info = 'Try %s/%s.' % (try_num, TRY_AMOUNT) try_info = 'Try %s/%s: ' % (try_num, TRY_AMOUNT)
test_result_glob = os.path.join( test_result_glob = os.path.join(
args.partition_path, args.partition_path,
'..', '..',
...@@ -96,27 +96,27 @@ def main(): ...@@ -96,27 +96,27 @@ def main():
'public', 'public',
'test-script-result', 'test-script-result',
) )
print(try_info + ' Waiting for data in %r.' % (test_result_glob,)) print(try_info + 'Waiting for data in %r.' % (test_result_glob,))
result_list = glob.glob(test_result_glob) result_list = glob.glob(test_result_glob)
if len(result_list) > 0: if len(result_list) > 0:
print(try_info + ' Data directory found, looking for results.') print(try_info + 'Data directory found, looking for results.')
result_path = result_list[0] result_path = result_list[0]
result_file_list = list((os.path.join(dirname, filename) result_file_list = list((os.path.join(dirname, filename)
for dirname, dirnames, filenames in os.walk(result_path) for dirname, dirnames, filenames in os.walk(result_path)
for filename in filenames for filename in filenames
)) ))
if len(result_file_list): if len(result_file_list):
print(try_info + ' No result posted, will check next try.') print(try_info + 'No result posted, will check next try.')
for result_file in result_file_list: for result_file in result_file_list:
print(try_info + ' Data found.') print(try_info + 'Data found.')
result_found = True result_found = True
result_file = os.path.abspath(result_file) result_file = os.path.abspath(result_file)
status_dict['command'] = result_file status_dict['command'] = result_file
result = open(result_file).read() result = open(result_file).read()
# remove result, as it is not required anymore # remove result, as it is not required anymore
os.unlink(result_file) os.unlink(result_file)
print(try_info + ' Analysis of result %r:' % (result_file,)) print(try_info + 'Analysis of result %r:' % (result_file,))
print(try_info + ' ' + result) print(try_info + result)
status_dict['stderr'] = 'Last result:\n%s' % (result,) status_dict['stderr'] = 'Last result:\n%s' % (result,)
if 'FATAL: all hosts have already failed -- aborting' in result: if 'FATAL: all hosts have already failed -- aborting' in result:
# failed # failed
...@@ -127,8 +127,8 @@ def main(): ...@@ -127,8 +127,8 @@ def main():
error_count=0 error_count=0
) )
finished = False finished = False
status_dict['stdout'] = try_info + ' Build not yet successful.' status_dict['stdout'] = try_info + 'Build not yet successful.'
print(try_info + ' %r: Found not yet finished run.' % (result_file,)) print(try_info + '%r: Found not yet finished run.' % (result_file,))
elif "\"msg\": \"[u'Build successful, connect to:', u'" in result: elif "\"msg\": \"[u'Build successful, connect to:', u'" in result:
# success # success
status_dict.update( status_dict.update(
...@@ -138,8 +138,8 @@ def main(): ...@@ -138,8 +138,8 @@ def main():
error_count=0 error_count=0
) )
finished = True finished = True
print(try_info + ' %r: Found finished successful run.' % (result_file,)) print(try_info + '%r: Found finished successful run.' % (result_file,))
status_dict['stdout'] = try_info + ' Build successful.' status_dict['stdout'] = try_info + 'Build successful.'
break break
else: else:
# unknown # unknown
...@@ -150,22 +150,22 @@ def main(): ...@@ -150,22 +150,22 @@ def main():
error_count=1 error_count=1
) )
status_dict['stdout'] = \ status_dict['stdout'] = \
try_info + ' Cannot find success nor failure result in the output' try_info + 'Cannot find success nor failure result in the output'
print(try_info + ' %r: Found unknown run.' % (result_file,)) print(try_info + '%r: Found unknown run.' % (result_file,))
finished = False finished = False
if finished: if finished:
break break
if try_num >= TRY_AMOUNT: if try_num >= TRY_AMOUNT:
msg = try_info + ' Time exceeded, success not found.' msg = try_info + 'Time exceeded, success not found.'
print(msg) print(msg)
status_dict.setdefault('stdout', '') status_dict.setdefault('stdout', '')
status_dict['stdout'] = '\n'.join([status_dict['stdout'], msg]) status_dict['stdout'] = '\n'.join([status_dict['stdout'], msg])
break break
try_num += 1 try_num += 1
print(try_info + ' Sleeping for %ss.' %(SLEEP_TIME,)) print(try_info + 'Sleeping for %ss.' %(SLEEP_TIME,))
sleep(SLEEP_TIME) sleep(SLEEP_TIME)
if not result_found: if not result_found:
status_dict['stdout'] = try_info + ' Test timed out and no result found.' status_dict['stdout'] = try_info + 'Test timed out and no result found.'
status_dict.update( status_dict.update(
test_count=1, test_count=1,
skip_count=0, skip_count=0,
......
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