How to use the pycsw.core.config.StaticContext function in pycsw

To help you get started, we’ve selected a few pycsw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github planetfederal / registry / test_registry.py View on Github external
def test_clear_records(client):
    response = client.delete('/catalog/{0}/csw'.format(catalog_slug))
    assert 200 == response.status_code
    assert 'removed' in response.content.decode('utf-8')

    # Delete records in pycsw database.
    context = config.StaticContext()
    delete_records(context,
                   registry.PYCSW['repository']['database'],
                   registry.PYCSW['repository']['table'])

    # Delete a catalog that has not been created previosuly.
    response = client.delete('/catalog/boom/csw')
    assert 404 == response.status_code
    assert 'does not exist' in response.content.decode('utf-8')
github planetfederal / registry / registry.py View on Github external
if not catalog_slug:
                LOGGER.error('Undefined catalog slug in command line input')
                sys.exit(1)
            if not check_index_exists(catalog_slug):
                create_index(catalog_slug)
            re_index_layers(catalog_slug)

        elif COMMAND == 'get_sysprof':
            LOGGER.debug(pycsw_admin.get_sysprof())

        elif COMMAND == 'export_records':
            if not xml_dirpath:
                LOGGER.error('Undefined xml files path in command line input')
                sys.exit(1)

            context = config.StaticContext()
            pycsw_admin.export_records(context, database, table, xml_dirpath)

        elif COMMAND == 'list_layers':
            context = config.StaticContext()
            repo = RegistryRepository(PYCSW['repository']['database'],
                                      context,
                                      table=PYCSW['repository']['table'])
            len_layers = int(repo.query('')[0])
            layers_list = repo.query('', maxrecords=len_layers)[1]
            for layer in layers_list:
                LOGGER.debug(layer.identifier)

        elif COMMAND == 'delete_records':
            if not catalog_slug:
                LOGGER.error('Undefined catalog slug in command line input')
                sys.exit(1)
github planetfederal / registry / registry.py View on Github external
context,
                                      table=PYCSW['repository']['table'])
            len_layers = int(repo.query('')[0])
            layers_list = repo.query('', maxrecords=len_layers)[1]
            for layer in layers_list:
                LOGGER.debug(layer.identifier)

        elif COMMAND == 'delete_records':
            if not catalog_slug:
                LOGGER.error('Undefined catalog slug in command line input')
                sys.exit(1)
            delete_records(catalog_slug)

        elif COMMAND == 'load_records':
            # First we load records to pycsw database.
            pycsw_admin.load_records(config.StaticContext(),
                                     database,
                                     table,
                                     xml_dirpath,
                                     recursive=False,
                                     force_update=True)


        sys.exit(0)

    management.execute_from_command_line()
github OSGeo / grass-addons / grass7 / gui / wxpython / wx.metadata / db.csw.admin / db.csw.admin.py View on Github external
self.COMMAND = None
        self.XML_DIRPATH = None
        self.CFG = None
        self.RECURSIVE = False
        self.OUTPUT_FILE = None
        self.CSW_URL = None
        self.XML = None
        self.XSD = None
        self.TIMEOUT = 30
        self.FORCE_CONFIRM = False
        self.METADATA = None
        self.DATABASE = None
        self.URL = None
        self.HOME = None
        self.TABLE = None
        self.CONTEXT = config.StaticContext()
github geopython / pycsw / bin / pycsw-admin.py View on Github external
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# =================================================================

from six.moves import configparser
from six.moves import input
import getopt
import sys

from pycsw.core import admin, config

CONTEXT = config.StaticContext()


def usage():
    """Provide usage instructions"""
    return '''
NAME
    pycsw-admin.py - pycsw admin utility

SYNOPSIS
    pycsw-admin.py -c  -f  [-h] [-p /path/to/records] [-r]

    Available options:

    -c    Command to be performed:
              - setup_db
              - load_records
github planetfederal / registry / registry.py View on Github external
def delete_records(catalog_slug):
    '''
    This function removes records from both csw database and elasticsearch
    '''
    pycsw_admin.delete_records(config.StaticContext(),
                               PYCSW['repository']['database'],
                               PYCSW['repository']['table'])
    message, status = delete_index(catalog_slug)

    return message, status
github geopython / pycsw / pycsw / server.py View on Github external
def __init__(self, rtconfig=None, env=None, version='2.0.2'):
        ''' Initialize CSW '''

        if not env:
            self.environ = os.environ
        else:
            self.environ = env

        self.context = config.StaticContext()

        # Lazy load this when needed
        # (it will permanently update global cfg namespaces)
        self.sruobj = None
        self.opensearchobj = None
        self.oaipmhobj = None

        # init kvp
        self.kvp = {}

        self.mode = 'csw'
        self.async = False
        self.soap = False
        self.request = None
        self.exception = False
        self.profiles = None