Exemplo n.º 1
0
from pilotTools import Logger, pythonPathCheck, PilotParams, getCommand

if __name__ == "__main__":

  pythonPathCheck()

  log = Logger( 'Pilot' )

  pilotParams = PilotParams()
  if pilotParams.debugFlag:
    log.setDebug()

  pilotParams.pilotRootPath = os.getcwd()
  pilotParams.pilotScript = os.path.realpath( sys.argv[0] )
  pilotParams.pilotScriptName = os.path.basename( pilotParams.pilotScript )
  log.debug( 'PARAMETER [%s]' % ', '.join( map( str, pilotParams.optList ) ) )

  log.info( "Executing commands: %s" % str( pilotParams.commands ) )
  if pilotParams.commandExtensions:
    log.info( "Requested command extensions: %s" % str( pilotParams.commandExtensions ) )

  for commandName in pilotParams.commands:
    command, module = getCommand( pilotParams, commandName, log )
    if command is not None:
      log.info( "Command %s instantiated from %s" % ( commandName, module ) )
      command.execute()
    else:
      log.error( "Command %s could not be instantiated" % commandName )
      sys.exit( -1 )

Exemplo n.º 2
0
    pilotParams = PilotParams()
    if pilotParams.debugFlag:
        log.setDebug()
    if pilotParams.keepPythonPath:
        pythonPathCheck()
    else:
        log.info("Clearing PYTHONPATH for child processes.")
        if "PYTHONPATH" in os.environ:
            os.environ["PYTHONPATH_SAVE"] = os.environ["PYTHONPATH"]
            os.environ["PYTHONPATH"] = ""

    pilotParams.pilotRootPath = os.getcwd()
    pilotParams.pilotScript = os.path.realpath(sys.argv[0])
    pilotParams.pilotScriptName = os.path.basename(pilotParams.pilotScript)
    log.debug('PARAMETER [%s]' % ', '.join(map(str, pilotParams.optList)))

    log.info("Executing commands: %s" % str(pilotParams.commands))
    if pilotParams.commandExtensions:
        log.info("Requested command extensions: %s" %
                 str(pilotParams.commandExtensions))

    for commandName in pilotParams.commands:
        command, module = getCommand(pilotParams, commandName, log)
        if command is not None:
            log.info("Command %s instantiated from %s" % (commandName, module))
            command.execute()
        else:
            log.error("Command %s could not be instantiated" % commandName)
            sys.exit(-1)