Example #1
0
def registerHandlers(project=None):
    """Read the project handlers from the init file handler parameters, and add to the registry."""

    # Get the project names
    projectOption = config.get('initialize', 'project_options')
    projectSpecs = splitRecord(projectOption)
    projectRegistry = getRegistry(ESGCET_PROJECT_HANDLER_GROUP)
    formatRegistry = getRegistry(ESGCET_FORMAT_HANDLER_GROUP)
    metadataRegistry = getRegistry(ESGCET_METADATA_HANDLER_GROUP)
    threddsRegistry = getRegistry(ESGCET_THREDDS_CATALOG_HOOK_GROUP)

    for projectName, projectDesc, search_order in projectSpecs:
        # process only the given project
        if (project is not None) and (projectName != project):
            continue

        # For each project: get the handler
        handler = config.get('project:'+projectName, HANDLER_OPTION, default=None)
        handlerName = config.get('project:'+projectName, PROJECT_NAME_OPTION, default=None)

        # Get the handler class and register it
        if handlerName is not None:
            registerHandlerName(projectRegistry, projectName, handlerName)
            setRegisterSearchOrder(projectName, search_order)
        elif handler is not None:
            m, cls = handler.split(':')
            register(projectRegistry, projectName, m, cls)
            setRegisterSearchOrder(projectName, search_order)
        else:
            info("No project handler spec found for project %s"%projectName)

        # Get the format handler class and register it
        formatHandlerName = config.get('project:'+projectName, FORMAT_NAME_OPTION, default=None)
        if formatHandlerName is not None:
            registerHandlerName(formatRegistry, projectName, formatHandlerName)
        else:
            registerHandlerName(formatRegistry, projectName, DEFAULT_FORMAT_NAME_OPTION)

        # Get the metadata handler class and register it
        metadataHandlerName = config.get('project:'+projectName, METADATA_NAME_OPTION, default=None)
        if metadataHandlerName is not None:
            registerHandlerName(metadataRegistry, projectName, metadataHandlerName)
        else:
            registerHandlerName(metadataRegistry, projectName, DEFAULT_METADATA_NAME_OPTION)

        # Get the thredds catalog hook if any
        threddsCatalogHookName = config.get('project:'+projectName, THREDDS_CATALOG_HOOK_OPTION, default=None)
        if threddsCatalogHookName is not None:
            registerHandlerName(threddsRegistry, projectName, threddsCatalogHookName)
Example #2
0
def registerHandlers():
    """Read the project handlers from the init file handler parameters, and add to the registry."""
    # Get the project names
    projectOption = config.get('initialize', 'project_options')
    projectSpecs = splitRecord(projectOption)
    projectRegistry = getRegistry(ESGCET_PROJECT_HANDLER_GROUP)
    formatRegistry = getRegistry(ESGCET_FORMAT_HANDLER_GROUP)
    metadataRegistry = getRegistry(ESGCET_METADATA_HANDLER_GROUP)
    threddsRegistry = getRegistry(ESGCET_THREDDS_CATALOG_HOOK_GROUP)
    for projectName, projectDesc, search_order in projectSpecs:

        # For each project: get the handler
        handler = config.get('project:'+projectName, HANDLER_OPTION, default=None)
        handlerName = config.get('project:'+projectName, PROJECT_NAME_OPTION, default=None)
        
        # Get the handler class and register it
        if handlerName is not None:
            registerHandlerName(projectRegistry, projectName, handlerName)
            setRegisterSearchOrder(projectName, search_order)
        elif handler is not None:
            m, cls = handler.split(':')
            register(projectRegistry, projectName, m, cls)
            setRegisterSearchOrder(projectName, search_order)
        else:
            info("No project handler spec found for project %s"%projectName)

        # Get the format handler class and register it
        formatHandlerName = config.get('project:'+projectName, FORMAT_NAME_OPTION, default=None)
        if formatHandlerName is not None:
            registerHandlerName(formatRegistry, projectName, formatHandlerName)
        else:
            registerHandlerName(formatRegistry, projectName, DEFAULT_FORMAT_NAME_OPTION)

        # Get the metadata handler class and register it
        metadataHandlerName = config.get('project:'+projectName, METADATA_NAME_OPTION, default=None)
        if metadataHandlerName is not None:
            registerHandlerName(metadataRegistry, projectName, metadataHandlerName)
        else:
            registerHandlerName(metadataRegistry, projectName, DEFAULT_METADATA_NAME_OPTION)

        # Get the thredds catalog hook if any
        threddsCatalogHookName = config.get('project:'+projectName, THREDDS_CATALOG_HOOK_OPTION, default=None)
        if threddsCatalogHookName is not None:
            registerHandlerName(threddsRegistry, projectName, threddsCatalogHookName)
Example #3
0
def getProgramsWhosLastUpdateTimesChanged():
  """ Returns a list of progams who's last-update-time has changed since it was installed. """
  programsWhosLastUpdateTimeChanged = []
  _registry = registry.getRegistry()
  for program, registeredInfo in _registry.iteritems():
    availableLastUpdateTime = permissions.getPermissions(program).get("last-update-time",None)
    installedLastUpdateTime = registeredInfo.get("last-update-time",None)
    if not availableLastUpdateTime == installedLastUpdateTime and not availableLastUpdateTime == None:
      programsWhosLastUpdateTimeChanged.append(program)
  return programsWhosLastUpdateTimeChanged
Example #4
0
def needsUpdate(program):
  """ Returns true if the program or any of it's dependencies need to be updated. """
  _registry = registry.getRegistry()
  dependencyTable = registry.getDependencyTable(availablePrograms.getAvailablePrograms())
  programsToCheck = dependencyTable[program]["depends-on"]
  programsToCheck.append(program)
  for programToCheck in programsToCheck:
    myPermissions = permissions.getPermissions(programToCheck)
    if not permissions.getLastUpdateTime(myPermissions) == _registry[programToCheck]["last-update-time"] and not permissions.getLastUpdateTime(myPermissions) == None:
      return True
  return False
Example #5
0
def getProgramsWhosLastUpdateTimesChanged():
    """ Returns a list of progams who's last-update-time has changed since it was installed. """
    programsWhosLastUpdateTimeChanged = []
    _registry = registry.getRegistry()
    for program, registeredInfo in _registry.iteritems():
        availableLastUpdateTime = permissions.getPermissions(program).get(
            "last-update-time", None)
        installedLastUpdateTime = registeredInfo.get("last-update-time", None)
        if not availableLastUpdateTime == installedLastUpdateTime and not availableLastUpdateTime == None:
            programsWhosLastUpdateTimeChanged.append(program)
    return programsWhosLastUpdateTimeChanged
Example #6
0
def needsUpdate(program):
    """ Returns true if the program or any of it's dependencies need to be updated. """
    _registry = registry.getRegistry()
    dependencyTable = registry.getDependencyTable(
        availablePrograms.getAvailablePrograms())
    programsToCheck = dependencyTable[program]["depends-on"]
    programsToCheck.append(program)
    for programToCheck in programsToCheck:
        myPermissions = permissions.getPermissions(programToCheck)
        if not permissions.getLastUpdateTime(
                myPermissions) == _registry[programToCheck][
                    "last-update-time"] and not permissions.getLastUpdateTime(
                        myPermissions) == None:
            return True
    return False