# Sub Argument 1 into the query string query = re.sub("ARG1", args[0], aliasDict[options.alias]) # Sub Argument 2 if re.search("ARG2", aliasDict[options.alias]) and len(args) > 1: query = re.sub("ARG2", args[1], query) # Alias was invalid else: print "Alias %s was not found current alias' are:" % options.alias for i in aliasDict: print i sys.exit(1) # Execute the Query columns, rows = cmgdbApi.sql(query) # Print out the column names colnames = "" for column in columns: colnames += str(column) + "\t" print colnames # Print out the results for row in rows: string = "" for column in row: string += str(column) + " ||\t" string = string.rstrip(" ||\t") print string
#!/bin/env python from CMGTools.Production.cmgdbApi import CmgdbApi import CMGTools.Production.eostools as eos import pprint db = CmgdbApi() db.connect() cols, rows = db.sql("select path_name, file_owner, number_files_bad, number_files_good from dataset_details where path_name like '%V5_4_0'") # pprint.pprint(rows) dead = [] good = [] nscanned = 0 for row in rows: # print row path = row[0] owner = row[1] nFiles = None if row[2] is not None and row[3] is not None: nFiles = row[2]+row[3] print path, nFiles dir = None if owner == 'cmgtools_group': dir = '/eos/cms/store/cmst3/group/cmgtools/CMG'+path elif owner == 'cmgtools': dir = '/eos/cms/store/cmst3/user/cmgtools/CMG'+path
# Sub Argument 1 into the query string query = re.sub("ARG1",args[0],aliasDict[options.alias]) # Sub Argument 2 if re.search("ARG2",aliasDict[options.alias]) and len(args)>1: query = re.sub("ARG2",args[1],query) # Alias was invalid else: print "Alias %s was not found current alias' are:" % options.alias for i in aliasDict: print i sys.exit(1) # Execute the Query columns, rows = cmgdbApi.sql(query) # Print out the column names colnames = "" for column in columns: colnames += str(column) + "\t" print colnames # Print out the results for row in rows: string = "" for column in row: string += str(column) + " ||\t" string = string.rstrip(" ||\t") print string
#!/bin/env python from CMGTools.Production.cmgdbApi import CmgdbApi import CMGTools.Production.eostools as eos import pprint db = CmgdbApi() db.connect() cols, rows = db.sql( "select path_name, file_owner, number_files_bad, number_files_good from dataset_details where path_name like '%V5_4_0'" ) # pprint.pprint(rows) dead = [] good = [] nscanned = 0 for row in rows: # print row path = row[0] owner = row[1] nFiles = None if row[2] is not None and row[3] is not None: nFiles = row[2] + row[3] print path, nFiles dir = None if owner == 'cmgtools_group': dir = '/eos/cms/store/cmst3/group/cmgtools/CMG' + path elif owner == 'cmgtools': dir = '/eos/cms/store/cmst3/user/cmgtools/CMG' + path
default=False) group.add_option("-f", "--file", action="store", dest="filename", help="""Specify the name of the file to be created""", default="empty_datasets.txt") parser.add_option_group(group) (options, args) = parser.parse_args() cmgdbApi = CmgdbApi(options.development) cmgdbApi.connect() columns, rows = cmgdbApi.sql( "select file_owner, path_name from dataset_details where dataset_is_open='Y' and (file_owner='cmgtools' or file_owner='cmgtools_group')" ) f = open(options.filename, 'w') for row in rows: fileown = row[0] dsName = row[1] if fileown == "--cmgtools": fileown = "cmgtools" lfnDir = castorBaseDir(fileown) + dsName castorDir = castortools.lfnToCastor(lfnDir) if castortools.datasetNotEmpty(castorDir, ".*root"):
"-f", "--file", action="store", dest="filename", help="""Specify the name of the file to be created""", default="empty_datasets.txt", ) parser.add_option_group(group) (options, args) = parser.parse_args() cmgdbApi = CmgdbApi(options.development) cmgdbApi.connect() columns, rows = cmgdbApi.sql( "select file_owner, path_name from dataset_details where dataset_is_open='Y' and (file_owner='cmgtools' or file_owner='cmgtools_group')" ) f = open(options.filename, "w") for row in rows: fileown = row[0] dsName = row[1] if fileown == "--cmgtools": fileown = "cmgtools" lfnDir = castorBaseDir(fileown) + dsName castorDir = castortools.lfnToCastor(lfnDir) if castortools.datasetNotEmpty(castorDir, ".*root"):