Beispiel #1
0
def main():
    fcType = 'FileCatalog'
    Script.registerSwitch(
        "f:", "file-catalog=",
        "   Catalog client type to use (default %s)" % fcType)
    Script.parseCommandLine(ignoreErrors=False)

    from DIRAC import gConfig, exit as dexit
    from DIRAC.Resources.Catalog.FileCatalogFactory import FileCatalogFactory

    __RCSID__ = "$Id$"

    fcType = gConfig.getValue("/LocalSite/FileCatalog", "")

    res = gConfig.getSections("/Resources/FileCatalogs", listOrdered=True)
    if not res['OK']:
        dexit(1)
    fcList = res['Value']
    if not fcType:
        if res['OK']:
            fcType = res['Value'][0]

    for switch in Script.getUnprocessedSwitches():
        if switch[0].lower() == "f" or switch[0].lower() == "file-catalog":
            fcType = switch[1]

    if not fcType:
        print("No file catalog given and defaults could not be obtained")
        sys.exit(1)

    from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI

    result = FileCatalogFactory().createCatalog(fcType)
    if not result['OK']:
        print(result['Message'])
        if fcList:
            print("Possible choices are:")
            for fc in fcList:
                print(' ' * 5, fc)
        sys.exit(1)
    print("Starting %s client" % fcType)
    catalog = result['Value']
    cli = FileCatalogClientCLI(catalog)
    cli.cmdloop()
Beispiel #2
0
for switch in Script.getUnprocessedSwitches():
    if switch[0].lower() == "f" or switch[0].lower() == "file-catalog":
        fcType = switch[1]

from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI

if fcType == "LcgFileCatalog" or fcType == "LFC":
    from DIRAC.Resources.Catalog.LcgFileCatalogClient import LcgFileCatalogClient
    cli = FileCatalogClientCLI(LcgFileCatalogClient())
    try:
        host = os.environ['LFC_HOST']
    except Exception, x:
        print "LFC_HOST environment variable not defined"
        sys.exit(1)
    print "Starting LFC FileCatalog client"
    cli.cmdloop()
elif fcType == "LcgFileCatalogProxy" or fcType == "LFCproxy":
    from DIRAC.Resources.Catalog.LcgFileCatalogProxyClient import LcgFileCatalogProxyClient
    cli = FileCatalogClientCLI(LcgFileCatalogProxyClient())
    print "Starting LFC Proxy FileCatalog client"
    cli.cmdloop()
elif fcType == "LcgFileCatalogCombined" or fcType == "LFCCombined":
    from DIRAC.Resources.Catalog.LcgFileCatalogCombinedClient import LcgFileCatalogCombinedClient
    cli = FileCatalogClientCLI(LcgFileCatalogCombinedClient())
    print "Starting LFC FileCatalog Combined client"
    cli.cmdloop()
elif fcType == "FileCatalog" or fcType == "DiracFC":
    from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient
    cli = FileCatalogClientCLI(FileCatalogClient())
    print "Starting DIRAC FileCatalog client"
    cli.cmdloop()
res = gConfig.getSections("/Resources/FileCatalogs",listOrdered = True)
if not res['OK']:
  dexit(1)
fcList = res['Value']
if not fcType:
  if res['OK']:
    fcType = res['Value'][0]

for switch in Script.getUnprocessedSwitches():
  if switch[0].lower() == "f" or switch[0].lower() == "file-catalog":
    fcType = switch[1]

if not fcType:
  print "No file catalog given and defaults could not be obtained"
  sys.exit(1)

from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI

result = FileCatalogFactory().createCatalog(fcType)
if not result['OK']:
  print result['Message']
  if fcList:
    print "Possible choices are:"
    for fc in fcList:
      print ' '*5,fc
  sys.exit(1)
print "Starting %s client" % fcType
catalog = result['Value']
cli = FileCatalogClientCLI( catalog )
cli.cmdloop()