def init_model(config):
    """
    This is a stub method which is called at application startup time.

    If you need to bind to a parsed database configuration, set up tables or
    ORM classes, or perform any database initialization, this is the
    recommended place to do it.

    For more information working with databases, and some common recipes,
    see https://pecan.readthedocs.io/en/latest/databases.html
    :param config:
    """
    custom_config = getattr(config, 'custom_config', {})
    mongo_config = getattr(custom_config, 'mongo_config', {})
    es_config = getattr(custom_config, 'es_config', {})
    cipher_secret = getattr(custom_config, 'cipher_secret', {})
    mongo_connect(host=mongo_config['host'],
                  port=mongo_config['port'],
                  username=mongo_config['global_db_username'],
                  password=mongo_config['global_db_password'],
                  db='global',
                  alias='global')
    es_options = []
    for option in es_config:
        es_opt = {'host': option[1]['host'], 'port': option[1]['port']}
        es_options.append(es_opt)
    global es, cipher
    es = Elasticsearch(es_options)
    cipher = Fernet(cipher_secret)
Example #2
0
    def __init__(self, conf='config.json'):
        """Initialize harpseal daemon.

        :param config: configuration file path
        """
        #: (:class:`asyncio.BaseEventLoop`) Base event-loop
        self.loop = None
        #: (:class:`harpseal.conf.Config`) Harpseal configuration
        self.config = Config(path=conf)
        #: (:class:`asyncio.Queue') Queue that saves plugin result to store data to mongodb
        self.queue = asyncio.Queue()
        #: (:class:`harpseal.web.WebServer`) Harpseal API server
        self.web = WebServer(self)
        #: (:class:`tuple`) Plugins
        self.plugins = tuple()
        #: (:class:`tuple`) Tasks (by plugins)
        self.tasks = tuple()

        Plugin._app = self

        conn_attrs = self.config['mongo']
        for k, v in conn_attrs.items():
            if k.startswith('_'):
                del conn_attrs[k]
        mongo_connect(**conn_attrs)
Example #3
0
File: app.py Project: ssut/harpseal
    def __init__(self, conf='config.json'):
        """Initialize harpseal daemon.

        :param config: configuration file path
        """
        #: (:class:`asyncio.BaseEventLoop`) Base event-loop
        self.loop = None
        #: (:class:`harpseal.conf.Config`) Harpseal configuration
        self.config = Config(path=conf)
        #: (:class:`asyncio.Queue') Queue that saves plugin result to store data to mongodb
        self.queue = asyncio.Queue()
        #: (:class:`harpseal.web.WebServer`) Harpseal API server
        self.web = WebServer(self)
        #: (:class:`tuple`) Plugins
        self.plugins = tuple()
        #: (:class:`tuple`) Tasks (by plugins)
        self.tasks = tuple()

        Plugin._app = self

        conn_attrs = self.config['mongo']
        for k, v in conn_attrs.items():
            if k.startswith('_'):
                del conn_attrs[k]
        mongo_connect(**conn_attrs)
Example #4
0
def connect():
    """
    Connect to a MongoDB with configured credentials.

    :return: DB connection object of type <class 'pymongo.mongo_client.MongoClient'>.
    """
    return mongo_connect(**config.CONNECTION)
Example #5
0
from pdb import set_trace as bp
import numbers

from mongoengine import Document, DynamicDocument
from mongoengine import StringField, DateTimeField, ListField, DictField, BooleanField
from mongoengine import ReferenceField, IntField
from mongoengine import connect as mongo_connect

from .configs import configs
from .exceptions import DoesNotExistError, MultipleObjectsFoundError

mongo_connect(
    db=configs['users']['dbname'],
    #username = configs['apps']['user'],
    #password = configs['apps']['password'],
    host=configs['users']['host'],
    connect=False,
)

DEFAULT_TOKEN_LIFETIME = 24 * 60 * 60 * 100  # 100 day in secounds TODO: This is only for dev
DEFAULT_PERMISSION_LIFETIME = 24 * 60 * 60 * 100  # 100 day in secounds TODO: This is only for dev.


async def get_all_relationships(sparql_db, entity_id):
    #TODO: Implement owl:inverseOf inside Vrituoso
    print('warning: ``inverseOf`` is not implemented yet inside Virtuoso')
    qstr = """
    select ?p ?o where {{
    {{
    <{0}> ?p ?o.
    FILTER NOT EXISTS {{ <{0}> a ?o .}}
Example #6
0
def connect(*args, **kwargs):
    mongo_connect(*args, **kwargs)
Example #7
0
 def _init_mongo(self):
     self._mongo_connection = mongo_connect('todotracker')
Example #8
0
 def _init_mongo(self):
     self._mongo_connection = mongo_connect('todotracker')
Example #9
0
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(__file__))

from mongoengine import connect as mongo_connect

mongo_connect("localhost_realty")
# mongo_connect("localhost_new_realty")


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "bg39+4b0%txbt%w)k_8np9y8&lm)$my7o&c&99epav(@dn=8dh"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

TEMPLATE_DEBUG = True

ASSETS_DEBUG = True
Example #10
0
"""
Django settings for franchising project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

from mongoengine import connect as mongo_connect
mongo_connect("localhost_realty")
# mongo_connect("localhost_new_realty")

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'bg39+4b0%txbt%w)k_8np9y8&lm)$my7o&c&99epav(@dn=8dh'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

TEMPLATE_DEBUG = True

ASSETS_DEBUG = True
Example #11
0
from mongoengine import connect as mongo_connect

from flask import Flask
from pages.tasks import Tasks
from pages.frontend import Frontend

app = Flask(__name__)
app.register_blueprint(Tasks)
app.register_blueprint(Frontend)
app.debug = True
mongo_connect('todotracker')

Example #12
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Survaider
import hug

from huey import RedisHuey
from mongoengine import connect as mongo_connect

from jupiter._config import version, redis_params, mongo_params, mongo_dbi


huey = RedisHuey(**redis_params)

mongo_connect(mongo_dbi, **mongo_params)

# Register Huey tasks
import jupiter.tasks.periodic
import jupiter.tasks.utils

@hug.get('/', versions=1)
def index():
  return "Survaider"

# Register APIs
from jupiter.api import (
  hooks as api_hooks,
  tasks as api_tasks,
)

@hug.extend_api('/hooks')
def attach_hooks_api():
Example #13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Survaider
import hug

from huey import RedisHuey
from mongoengine import connect as mongo_connect

from jupiter._config import version, redis_params, mongo_params, mongo_dbi

huey = RedisHuey(**redis_params)

mongo_connect(mongo_dbi, **mongo_params)

# Register Huey tasks
import jupiter.tasks.periodic
import jupiter.tasks.utils


@hug.get('/', versions=1)
def index():
    return "Survaider"


# Register APIs
from jupiter.api import (
    hooks as api_hooks,
    tasks as api_tasks,
)