Beispiel #1
0
def main():
  Script.parseCommandLine()

  from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient
  from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient

  prodClient = ProductionClient()
  transClient = TransformationClient()

  # get arguments
  args = Script.getPositionalArgs()
  if len(args) == 3:
    parentTransID = args[2]
  elif len(args) == 2:
    parentTransID = ''
  else:
    Script.showHelp(exitCode=1)

  prodID = args[0]
  transID = args[1]

  res = transClient.getTransformation(transID)
  if not res['OK']:
    DIRAC.gLogger.error('Failed to get transformation %s: %s' % (transID, res['Message']))
    DIRAC.exit(-1)

  transID = res['Value']['TransformationID']

  if parentTransID:
    res = transClient.getTransformation(parentTransID)
    if not res['OK']:
      DIRAC.gLogger.error('Failed to get transformation %s: %s' % (parentTransID, res['Message']))
      DIRAC.exit(-1)
    parentTransID = res['Value']['TransformationID']

  res = prodClient.getProduction(prodID)
  if not res['OK']:
    DIRAC.gLogger.error('Failed to get production %s: %s' % (prodID, res['Message']))
    DIRAC.exit(-1)

  prodID = res['Value']['ProductionID']
  res = prodClient.addTransformationsToProduction(prodID, transID, parentTransID)
  if not res['OK']:
    DIRAC.gLogger.error(res['Message'])
    DIRAC.exit(-1)

  if parentTransID:
    msg = 'Transformation %s successfully added to production %s with parent transformation %s' % \
          (transID, prodID, parentTransID)
  else:
    msg = 'Transformation %s successfully added to production %s with no parent transformation' %  \
          (transID, prodID)

  DIRAC.gLogger.notice(msg)

  DIRAC.exit(0)
Beispiel #2
0
def main():
    # Registering arguments will automatically add their description to the help menu
    Script.registerArgument("prodID:         Production ID")
    Script.registerArgument("transID:        Transformation ID")
    Script.registerArgument("parentTransID:  Parent Transformation ID", default="", mandatory=False)
    _, args = Script.parseCommandLine()

    from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient
    from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient

    prodClient = ProductionClient()
    transClient = TransformationClient()

    # get arguments
    prodID, transID, parentTransID = Script.getPositionalArgs(group=True)
    if len(args) > 3:
        Script.showHelp(exitCode=1)

    res = transClient.getTransformation(transID)
    if not res["OK"]:
        DIRAC.gLogger.error("Failed to get transformation %s: %s" % (transID, res["Message"]))
        DIRAC.exit(-1)

    transID = res["Value"]["TransformationID"]

    if parentTransID:
        res = transClient.getTransformation(parentTransID)
        if not res["OK"]:
            DIRAC.gLogger.error("Failed to get transformation %s: %s" % (parentTransID, res["Message"]))
            DIRAC.exit(-1)
        parentTransID = res["Value"]["TransformationID"]

    res = prodClient.getProduction(prodID)
    if not res["OK"]:
        DIRAC.gLogger.error("Failed to get production %s: %s" % (prodID, res["Message"]))
        DIRAC.exit(-1)

    prodID = res["Value"]["ProductionID"]
    res = prodClient.addTransformationsToProduction(prodID, transID, parentTransID)
    if not res["OK"]:
        DIRAC.gLogger.error(res["Message"])
        DIRAC.exit(-1)

    if parentTransID:
        msg = "Transformation %s successfully added to production %s with parent transformation %s" % (
            transID,
            prodID,
            parentTransID,
        )
    else:
        msg = "Transformation %s successfully added to production %s with no parent transformation" % (transID, prodID)

    DIRAC.gLogger.notice(msg)

    DIRAC.exit(0)
Beispiel #3
0
transID = res['Value']['TransformationID']

if parentTransID:
  res = transClient.getTransformation(parentTransID)
  if not res['OK']:
    DIRAC.gLogger.error('Failed to get transformation %s: %s' % (parentTransID, res['Message']))
    DIRAC.exit(-1)
  parentTransID = res['Value']['TransformationID']

res = prodClient.getProduction(prodID)
if not res['OK']:
  DIRAC.gLogger.error('Failed to get production %s: %s' % (prodID, res['Message']))
  DIRAC.exit(-1)

prodID = res['Value']['ProductionID']
res = prodClient.addTransformationsToProduction(prodID, transID, parentTransID)
if not res['OK']:
  DIRAC.gLogger.error(res['Message'])
  DIRAC.exit(-1)

if parentTransID:
  msg = 'Transformation %s successfully added to production %s with parent transformation %s' % \
        (transID, prodID, parentTransID)
else:
  msg = 'Transformation %s successfully added to production %s with no parent transformation' %  \
        (transID, prodID)

DIRAC.gLogger.notice(msg)


DIRAC.exit(0)