def validateArguments( options, args ):
    if options.verbose:
        rootCMSYAAT = Logging.getLogger('CMSYAAT')
        rootCMSYAAT.setLevel( DEBUG ) 
    return True
#!/usr/bin/env python2.6

import os
import sys
import pwd
import json

from CMSYAAT.RequestManager import RequestManager
from CMSYAAT.Utilities import Logging
from CMSYAAT.Utilities import CommandLineHandler

# TODO: Get some common options parsing
commonArgs = ['endpoint']
parser = CommandLineHandler.getParser(commonArgs)

(options, args) = parser.parse_args()
CommandLineHandler.validateArguments(options, args)

reqmgr = RequestManager( endpoint = options.endpoint )
for request in args:
    requestDict = json.loads( open( request, 'r' ).read() )
    newRequest = reqmgr.newRequest()
    newRequest.setRequestDict( requestDict )
    reqmgr.submitRequest( newRequest )
    print newRequest.getWorkflowName()

sys.exit( 0 )
Internal helpers to talk to the request manager

import json
import httplib
import urllib
import datetime
from httplib import HTTPException
from CMSYAAT.Utilities.Proxy import requireProxy
from CMSYAAT.Utilities import Logging
logging = Logging.getLogger('CMSYAAT.ReqMgrImpl')

from WMCore.Services.Requests import Requests, JSONRequests

class RequestManagerImpl:
    Not a public interface, this is gross for now
    def __init__(self):
        self.headers = {'User-agent':                                        
                            "CMSYAAT 1.0"}

    def checkStatusOrComplain( self, wantedStatus, retval, status, reason ):
        if status != wantedStatus:
            raise RuntimeError, ("Got HTTP code %s, expected %s \n" +
                                 "reason: %s \n" +
                                 "data: %s \n") % (status, wantedStatus,
                                                    reason, retval )