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

from  eTraveler.clientAPI.connection import Connection

fpath = "/Users/jrb/lsst-camera-dh/eTraveler-travelerDefinition/test/yaml/simpleMulti.yaml"
# Uncomment following to exercise failure
#fpath = "/Users/jrb/lsst-camera-dh/eTraveler-travelerDefinition/test/yaml/badNames.yaml"

# Uncomment the following to exercise calls using 'contents' keyword arg.
# instead of 'filepath'
#f = open(fpath)
#c = ''
#next = f.readline()
#while len(next) > 0:
#      c += next
#      next = f.readline()
      
myConn = Connection('jrb', 'Raw', prodServer=True)
try: 
    msg = myConn.validateYaml(filepath=fpath)
    #msg = myConn.uploadYaml(filepath=fpath, reason='testing')
    #msg = myConn.validateYaml(contents=c)

    print("Results from validate: ", msg)
    sys.exit(0)
except Exception as msg:
    print('Validation failed with exception: ')
    print(msg)
    sys.exit(1)

