Beispiel #1
0
def mast_authenticate(token=None):
    """Verify MAST authentication status, login if needed."""
    if Mast.authenticated() is False:
        if token is None:
            raise ValueError(
                'You are not authenticated in MAST. Please provide a valid token.'
            )
        else:
            Mast.login(token=token)
def log_into_mast(request):
    """Login via astroquery.mast if user authenticated in web app.

    Parameters
    ----------
    request : HttpRequest object
        Incoming request from the webpage

    """
    if Mast.authenticated():
        return True

    # get the MAST access token if present
    access_token = str(get_mast_token(request))

    # authenticate with astroquery.mast if necessary
    if access_token != 'None':
        Mast.login(token=access_token)
        return Mast.authenticated()
    else:
        return False
"""

import astropy
from astropy.table import Table
from astropy.time import Time
from astroquery.mast import Mast
from bokeh.embed import components
from bokeh.plotting import figure

from .utils import get_config

# should use oauth.register_oauth()?
settings = get_config()
mast_token = settings['mast_token']

Mast.login(token=mast_token)

# could eventually be moved to constants.py
mast_edb_timeseries_service = 'Mast.JwstEdb.GetTimeseries.All'
mast_edb_dictionary_service = 'Mast.JwstEdb.Dictionary'
mast_edb_mnemonic_service = 'Mast.JwstEdb.Mnemonics'


class EdbMnemonic:
    """Class to hold and manipulate results of DMS EngDB queries."""
    def __init__(self, mnemonic_identifier, start_time, end_time, data, meta,
                 info):
        """Populate attributes.

        Parameters
        ----------