示例#1
0
def main():
    # Registering arguments will automatically add their description to the help menu
    Script.registerArgument((
        "URL:            URL of the service to ping (instead of System and Service)",
        "System/Service: Full component name (ie: WorkloadManagement/Matcher)",
        "System:         Name of the DIRAC system (ie: WorkloadManagement)",
    ))
    Script.registerArgument(
        " Service:        Name of the DIRAC service (ie: Matcher)",
        mandatory=False)
    _, args = Script.parseCommandLine(ignoreErrors=True)
    system = None
    service = None
    url = None
    if len(args) == 1:
        # it is a URL
        if args[0].startswith("dips://"):
            url = args[0]
        # It is System/Service
        else:
            sys_serv = args[0].split("/")
            if len(sys_serv) != 2:
                Script.showHelp(exitCode=1)
            else:
                system, service = sys_serv

    elif len(args) == 2:
        system, service = args[0], args[1]
    else:
        Script.showHelp(exitCode=1)

    from DIRAC.Interfaces.API.Dirac import Dirac

    dirac = Dirac()
    exitCode = 0

    result = dirac.pingService(system, service, printOutput=True, url=url)

    if not result:
        print("ERROR: Null result from ping()")
        exitCode = 2
    elif not result["OK"]:
        print("ERROR: ", result["Message"])
        exitCode = 2

    DIRAC.exit(exitCode)
def main():
    Script.parseCommandLine(ignoreErrors=True)
    args = Script.getPositionalArgs()
    system = None
    service = None
    url = None
    if len(args) == 1:
        # it is a URL
        if args[0].startswith('dips://'):
            url = args[0]
        # It is System/Service
        else:
            sys_serv = args[0].split('/')
            if len(sys_serv) != 2:
                Script.showHelp(exitCode=1)
            else:
                system, service = sys_serv

    elif len(args) == 2:
        system, service = args[0], args[1]
    else:
        Script.showHelp(exitCode=1)

    from DIRAC.Interfaces.API.Dirac import Dirac
    dirac = Dirac()
    exitCode = 0

    result = dirac.pingService(system, service, printOutput=True, url=url)

    if not result:
        print('ERROR: Null result from ping()')
        exitCode = 2
    elif not result['OK']:
        print('ERROR: ', result['Message'])
        exitCode = 2

    DIRAC.exit(exitCode)
示例#3
0
    if args[0].startswith('dips://'):
        url = args[0]
    # It is System/Service
    else:
        sys_serv = args[0].split('/')
        if len(sys_serv) != 2:
            Script.showHelp()
        else:
            system, service = sys_serv

elif len(args) == 2:
    system, service = args[0], args[1]
else:
    Script.showHelp()

from DIRAC.Interfaces.API.Dirac import Dirac

dirac = Dirac()
exitCode = 0

result = dirac.pingService(system, service, printOutput=True, url=url)

if not result:
    print('ERROR: Null result from ping()')
    exitCode = 2
elif not result['OK']:
    print('ERROR: ', result['Message'])
    exitCode = 2

DIRAC.exit(exitCode)
  if args[0].startswith('dips://'):
    url = args[0]
  # It is System/Service
  else:
    sys_serv = args[0].split('/')
    if len(sys_serv) != 2:
      Script.showHelp()
    else:
      system, service = sys_serv

elif len(args) == 2:
  system, service = args[0], args[1]
else:
  Script.showHelp()


from DIRAC.Interfaces.API.Dirac import Dirac
dirac = Dirac()
exitCode = 0

result = dirac.pingService(system, service, printOutput=True, url=url)

if not result:
  print 'ERROR: Null result from ping()'
  exitCode = 2
elif not result['OK']:
  print 'ERROR: ', result['Message']
  exitCode = 2

DIRAC.exit(exitCode)