#!/usr/bin/env python
from __future__ import print_function
import sys

from  eTraveler.clientAPI.connection import Connection


myConn = Connection('jrb', 'Prod', prodServer=False, appSuffix='-jrb')

rsp = {}
htype='LCA-10753_RSA'
traveler='SR-RSA-ASY-02'
step = 'SR-RSA-ASY-02_Analyze-Data-Run1'

print('Invoking getManualFilepathsStep with arguments ')
print('htype=',htype, ' travelerName=',traveler, ' stepName=',step)
#,' experimentSN=',eSN
try:
    rsp = myConn.getManualFilepathsStep(htype=htype, stepName=step,
                                        travelerName=traveler)

    print('Data returned for ',len(rsp), ' components')
    for esn in rsp:
        print('For component %s \n' % (esn))
        esnData = rsp[esn]
        for k in esnData:
            if k != 'steps':
                print(k,' : ', esnData[k])
        steps = esnData['steps']
        for s in steps:
            print('For stepName %s \n' % (s) )
            inforecords = steps[s]
            for patname in inforecords:
                print('Input pattern name: ',patname)

                for field in inforecords[patname]:
                    print(field, ':', inforecords[patname][field])
    sys.exit(0)
except Exception as msg:
    print('Operation failed with exception: ')
    print(msg)
    sys.exit(1)

