Example #1
0
def test_session_options():
    """Test that http sessions receive proper options."""
    auth = ('foo', 'bar')
    session_manager.set_session_options(auth=auth)
    try:
        session = session_manager.create_session()
        assert session.auth == auth
    finally:
        session_manager.set_session_options()
Example #2
0
def test_session_options():
    """Test that http sessions receive proper options."""
    auth = ('foo', 'bar')
    session_manager.set_session_options(auth=auth)
    try:
        session = session_manager.create_session()
        assert session.auth == auth
    finally:
        session_manager.set_session_options()
Example #3
0
    def get_engine(self):
        """
        Retrieves spatial dataset engine
        """
        engine = None

        if self.engine == self.GEOSERVER:
            engine = GeoServerSpatialDatasetEngine(endpoint=self.endpoint,
                                                   username=self.username,
                                                   password=self.password)
            engine.public_endpoint = self.public_endpoint

        elif self.engine == self.THREDDS:
            if self.username and self.password:
                session_manager.set_session_options(auth=(str(self.username),
                                                          str(self.password)))

            catalog_endpoint = str(self.endpoint).rstrip('/') + '/catalog.xml'
            engine = TDSCatalog(str(catalog_endpoint))

        return engine
from django.shortcuts import render
from django.shortcuts import render
from tethys_sdk.permissions import login_required
from tethys_sdk.gizmos import SelectInput
from .app import ThreddsTutorial as app
from .thredds_methods import parse_datasets
from django.http import HttpResponseNotAllowed, JsonResponse
from .thredds_methods import parse_datasets, get_layers_for_wms
from siphon.http_util import session_manager
session_manager.set_session_options(verify=False)
import logging

log = logging.getLogger(__name__)


@login_required()
def home(request):
    """
    Controller for the app home page.
    """
    catalog = app.get_spatial_dataset_service(app.THREDDS_SERVICE_NAME, as_engine=True)

    # Retrieve dataset options from the THREDDS service
    # Retrieve dataset options from the THREDDS service
    log.info('Retrieving Datasets...')
    datasets = parse_datasets(catalog)
    initial_dataset_option = datasets[0]
    log.debug(datasets)
    log.debug(initial_dataset_option)

    dataset_select = SelectInput(
Example #5
0
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import metpy.calc as mpcalc
import numpy as np
import os
import sys


# ----------------------------------------------------------------------------------------------------------------------
# IMPORTANT:
# You need to insert *your* UCAR RDA username and password in the below line instead of the word username and password.
# Because they're strings, they need to be within the single quotes!
# ----------------------------------------------------------------------------------------------------------------------
session_manager.set_session_options(auth=('username', 'password'))


def fancymap():
    """
    The custom function "fancymap()" improves the appearance of our output map.
    """
    axes_bbox = ax.get_position()
    left = axes_bbox.x1 + 0.015
    bottom = axes_bbox.y0
    width = 0.015
    height = axes_bbox.y1 - bottom
    cax = fig.add_axes([left, bottom, width, height])
    cbar = plt.colorbar(im, cax=cax, ticks=clevs, orientation='vertical')
    cbar.ax.tick_params(labelsize=10)
    gl = ax.gridlines(crs=pc, draw_labels=False, linewidth=0.35)
Example #6
0
# Copyright (c) 2013-2015 Siphon Contributors.
# Distributed under the terms of the BSD 3-Clause License.
# SPDX-License-Identifier: BSD-3-Clause
"""
===============
THREDDS Catalog
===============

Read a catalog from THREDDS Data Server.

This example grabs a remote catalog and prints out the catalog references
contained within.
"""

# This is currently a placeholder for a better example
from __future__ import print_function

from siphon.catalog import TDSCatalog
from siphon.http_util import session_manager

###########################################
cat = TDSCatalog('http://thredds.ucar.edu/thredds/catalog.xml')
print(list(cat.catalog_refs))

###########################################
# Basic HTTP authentication can also be used by using the HTTP session manager
# and setting some default options for HTTP sessions
session_manager.set_session_options(auth=('username', 'password'))
cat = TDSCatalog('https://rda.ucar.edu/thredds/catalog.xml')