Beispiel #1
0
    def __init__(self):
        # Create a GridFS handle.
        db = config.getMongoClient(timeout=1.0)['AzraelGridDB']
        self.fs = gridfs.GridFS(db)

        # Create a Class-specific logger.
        name = '.'.join([__name__, self.__class__.__name__])
        self.logit = logging.getLogger(name)
def deleteAllGrids():
    """
    Delete all currently defined grids.

    :return: Success
    """
    global _DB_Grid
    client = config.getMongoClient()
    name = 'azrael_grid'
    client.drop_database(name)
    _DB_Grid = client[name]

    return RetVal(True, None, None)
Beispiel #3
0
    def connect(self):
        """
        Attempt to connect to MongoDB and return the client handle.

        Raises IOError if the connection failed.
        """
        try:
            # Connect to Mongo. Since this will not throw error even when
            # there is no running Mongo instance we need to make a dummy
            # query. This will throw an error if there is no running Mongo
            # instance.
            db = config.getMongoClient(timeout=1.0)
            db.database_names()
            return db
        except (pymongo.errors.ConnectionFailure,
                pymongo.errors.ServerSelectionTimeoutError):
            raise IOError('Could not connect to MongoDB')
All grids have a spatial granularity. It is possible to set/query values at any
(floating point) position but the set/get functions will always round it to the
nearest granularity multiple.

Internally, the engine only adds non-zero values to the database, and removes
all those set to zero.
"""
import logging
import numpy as np
import azrael.config as config

from IPython import embed as ipshell
from azrael.aztypes import typecheck, RetVal

# Global database handle.
_DB_Grid = config.getMongoClient()['azrael_grid']


# Create module logger.
logit = logging.getLogger('azrael.' + __name__)


def deleteAllGrids():
    """
    Delete all currently defined grids.

    :return: Success
    """
    global _DB_Grid
    client = config.getMongoClient()
    name = 'azrael_grid'