#!/usr/bin/env python3
#
# Merge the participant results of a run by this tool into a
# test-standard result.
#

import pscheduler

input = pscheduler.json_load(exit_on_error=True);

try:
    result0 = input['results'][0]
    result = {
        'schema': 1,
        'succeeded': result0['succeeded'],
        'duration': result0['result']['time-slept']
    }
except (KeyError, TypeError) as ex:
    pscheduler.fail("Missing result in returned data: {}".format(ex))

pscheduler.succeed_json(result)
