def main(): Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) else: prodID = args[0] res = prodClient.getProduction(prodID) if res['OK']: prod = res['Value'] else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) print('Description for production %s:\n' % prodID) print(prod['Description']) DIRAC.exit(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)
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)
def main(): Script.parseCommandLine() from DIRAC.Core.Utilities.PrettyPrint import printTable from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp(exitCode=1) else: prodID = args[0] res = prodClient.getProduction(prodID) fields = [ 'ProductionName', 'Status', 'ProductionID', 'CreationDate', 'LastUpdate', 'AuthorDN', 'AuthorGroup'] records = [] if res['OK']: prodList = res['Value'] if not isinstance(res['Value'], list): prodList = [res['Value']] for prod in prodList: records.append( [ str( prod['ProductionName']), str( prod['Status']), str( prod['ProductionID']), str( prod['CreationDate']), str( prod['LastUpdate']), str( prod['AuthorDN']), str( prod['AuthorGroup'])]) else: DIRAC.gLogger.error(res['Message']) DIRAC.exit(-1) printTable(fields, records) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.Core.Utilities.PrettyPrint import printTable from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments prodID = args[0] res = prodClient.getProduction(prodID) fields = [ "ProductionName", "Status", "ProductionID", "CreationDate", "LastUpdate", "AuthorDN", "AuthorGroup" ] records = [] if res["OK"]: prodList = res["Value"] if not isinstance(res["Value"], list): prodList = [res["Value"]] for prod in prodList: records.append([ str(prod["ProductionName"]), str(prod["Status"]), str(prod["ProductionID"]), str(prod["CreationDate"]), str(prod["LastUpdate"]), str(prod["AuthorDN"]), str(prod["AuthorGroup"]), ]) else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) printTable(fields, records) DIRAC.exit(0)
def main(): # Registering arguments will automatically add their description to the help menu Script.registerArgument("prodID: Production ID") _, args = Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments prodID = args[0] res = prodClient.getProduction(prodID) if res["OK"]: prod = res["Value"] else: DIRAC.gLogger.error(res["Message"]) DIRAC.exit(-1) print("Description for production %s:\n" % prodID) print(prod["Description"]) DIRAC.exit(0)
])) Script.parseCommandLine() from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient prodClient = ProductionClient() # get arguments args = Script.getPositionalArgs() if (len(args) != 1): Script.showHelp() else: prodID = args[0] res = prodClient.getProduction(prodID) fields = [ 'ProductionName', 'Status', 'ProductionID', 'CreationDate', 'LastUpdate', 'AuthorDN', 'AuthorGroup'] records = [] if res['OK']: prodList = res['Value'] if not isinstance(res['Value'], list): prodList = [res['Value']]