Ejemplo n.º 1
0
def translate_date_based_context(context, observatory=None):
    """Check to see if `input_context` is based upon date rather than a context filename.  If it's 
    just a filename,  return it.  If it's a date spec,  ask the server to interpret the date into 
    a context filename.   If it's a date spec and not `connected`,  raise an exception.
    """
    if config.is_mapping(context):
        return context

    if observatory is None:
        for observatory in ALL_OBSERVATORIES:
            if context.startswith(observatory):
                break
        else:
            raise CrdsError("Cannot determine observatory to translate mapping '{}'".format(context))

    info = get_config_info(observatory)

    if context == info.observatory + "-operational":
        return info["operational_context"]
    elif context == info.observatory + "-edit":
        return info["edit_context"]
    elif context == info.observatory + "-versions":
        return info["versions_context"]

    if not info.connected:
        raise CrdsError("Specified CRDS context by date '{}' and CRDS server is not reachable.".format(context))
    try:
        translated = api.get_context_by_date(context, observatory=info.observatory)
    except Exception as exc:
        log.error("Failed to translate date based context", repr(context), ":", str(exc))
        raise

    log.verbose("Date based context spec", repr(context), "translates to", repr(translated) + ".", verbosity=80)
    return translated
Ejemplo n.º 2
0
def get_symbolic_mapping(mapping, observatory=None, cached=True):
    """Return a loaded mapping object,  first translating any date based or
    named contexts into a more primitive serial number only mapping name.

    This is basically the symbolic form of rmap.asmapping().  Since the default
    setting of 'cached' is True,  it performs much like crds.get_cached_mapping()
    but also accepts abstract or date-based names.
    
    Typically the latest files submitted on the server but not yet operational:
    
    >> get_symbolic_mapping("jwst-edit")
    PipelineMapping('jwst_0153.pmap')

    What's running in the pipeline now:

    >> get_symbolic_mapping("jwst-operational")
    PipelineMapping('jwst_0126.pmap')

    What was running for a particular instrument, type, and date:

    >> get_symbolic_mapping("jwst-miri-flat-2015-01-01T00:20:05")
    ReferenceMapping('jwst_miri_flat_0012.rmap')

    WARNING:  this is a high level feature which *requires* a server connection
    to interpret the symbolic name into a primitive name.
    """
    abs_mapping = api.get_context_by_date(mapping, observatory)
    return crds.asmapping(abs_mapping, cached=cached)
Ejemplo n.º 3
0
def translate_date_based_context(context, observatory=None):
    """Check to see if `input_context` is based upon date rather than a context filename.  If it's 
    just a filename,  return it.  If it's a date spec,  ask the server to interpret the date into 
    a context filename.   If it's a date spec and not `connected`,  raise an exception.
    """
    if config.is_mapping(context):
        return context

    if observatory is None:
        for observatory in ALL_OBSERVATORIES:
            if context.startswith(observatory):
                break
        else:
            raise CrdsError("Cannot determine observatory to translate mapping '{}'".format(context))

    info = get_config_info(observatory)

    if context == info.observatory + "-operational":
        return info["operational_context"]
    elif context == info.observatory + "-edit":
        return info["edit_context"]
    elif context == info.observatory + "-versions":
        return info["versions_context"]

    if not info.connected:
        raise CrdsError("Specified CRDS context by date '{}' and CRDS server is not reachable.".format(context))
    try:
        translated = api.get_context_by_date(context, observatory=info.observatory)
    except Exception as exc:
        log.error("Failed to translate date based context", repr(context), ":", str(exc))
        raise

    log.verbose("Date based context spec", repr(context), "translates to", repr(translated) + ".", verbosity=80)
    return translated
Ejemplo n.º 4
0
def translate_date_based_context(info, context):
    """Check to see if `input_context` is based upon date rather than a context filename.  If it's 
    just a filename,  return it.  If it's a date spec,  ask the server to interpret the date into 
    a context filename.   If it's a date spec and not `connected`,  raise an exception.
    """
    if config.is_mapping(context):
        return context
    else:
        if not info.connected:
            if context == info.observatory + "-operational":
                return info["operational_context"]
            else:
                raise CrdsError("Specified CRDS context by date '{}' and CRDS server is not reachable.".format(context))
        try:
            translated = api.get_context_by_date(context, observatory=info.observatory)
        except Exception as exc:
            log.error("Failed to translate date based context", repr(context), ":", str(exc))
            raise
        log.verbose("Date based context spec", repr(context), "translates to", repr(translated) + ".", verbosity=80)
        return translated