#!/usr/bin/env python3
#
# Return participant-specific data for a run
#

import pscheduler
import random
import sys

json = pscheduler.json_load(exit_on_error=True)

# TODO: Validate the input

random.seed()

result = {}

try:
    participant = json['participant']
except KeyError:
    pscheduler.fail("Missing participant")

if participant == 0:

    # Nothing interesing for participant 0
    pass

elif participant == 1:

    try:
        result['listen-port'] = json['test']['spec']['port'] 
    except KeyError:
       result['listen-port'] = random.randint(5890,5899)

else:

    pscheduler.fail("Invalid participant number for this test")

pscheduler.succeed_json(result)
