Exemplo n.º 1
0
    def get_client(cls):
        """Returns a configured StrictRedis client.

        :returns StrictRedis: Redis client.
        """
        return redis.StrictRedis(
            host=config.get('external.redis.host'),
            port=config.get('external.redis.port'),
            db=config.get('external.redis.db', 0),
        )
Exemplo n.º 2
0
    def get_client(cls):
        """Returns a configured StrictRedis client.

        :returns StrictRedis: Redis client.
        """
        return redis.StrictRedis(
            host=config.get("external.redis.host"),
            port=config.get("external.redis.port"),
            db=config.get("external.redis.db", 0),
        )
Exemplo n.º 3
0
def get_engine(url=None):
    """Returns Engine for a URL.

    If URL is not provided it will be fetched from the configuration.

    :param str url: (optional)
    :returns Engine:
    """
    url = url or config.get('external.database.sqlalchemy.url')

    return create_engine(url)
Exemplo n.º 4
0
def get_engine(url=None):
    """Returns Engine for a URL.

    If URL is not provided it will be fetched from the configuration.

    :param str url: (optional)
    :returns Engine:
    """
    url = url or config.get('external.database.sqlalchemy.url')

    return create_engine(url)
Exemplo n.º 5
0
    def send_email(cls, email_contents):
        """Sends an email via SMTP.

        :param dict email_contents:
            from_email - Email address to send FROM
            to_email - Email address to send TO
            subject - Subject of email
            plain_message - Plaintext messgae
            rich_message - Rich/HTML message
        """
        mailer = Mailer({
            'manager.use':
            'immediate',
            'transport.use':
            'smtp',
            'transport.host':
            config.get('secrets.smtp.host'),
            'transport.port':
            config.get('secrets.smtp.port'),
            'transport.username':
            config.get('secrets.smtp.username'),
            'transport.password':
            config.get('secrets.smtp.password'),
            'transport.timeout':
            10,
        })

        mailer.start()

        message = Message(
            author=email_contents['from_email'],
            to=email_contents['to_email'],
            subject=email_contents['subject'],
            plain=email_contents.get('plain_message')
            or '-- message not available --',
            rich=email_contents.get('rich_message'),
        )

        mailer.send(message)
        mailer.stop()
Exemplo n.º 6
0
if __name__ == '__main__':
    datastores.create_tables()
    datastores.initialize()

    def create_pipeline(name):
        pipeline = PipelineImportService.import_pipeline(
            json.load(open('data/{}.pipeline.json'.format(name)))
        )

        print '>> Created pipeline: {} - {}'.format(
            pipeline.name,
            pipeline.id,
        )

    for seed_file in config.get('seed_files', []):
        create_pipeline(seed_file)

#      pipeline = create_datastore(PipelineStore(
#          id='96feda22-f80d-4cee-ad51-4e18de0b655a',
#          name='XKCD Check',
#      ))

#      create_datastore(PipelineScheduleStore(
#          pipeline_id=pipeline.id,

#          # Interval Schedule
#          schedule=str(21600),  # 6hrs in seconds
#          type='interval',

#          # Cron schedule
Exemplo n.º 7
0
import os

from ocelot import config
from ocelot.tests.test_case import (  # noqa
    DatabaseTestCase, fixtures_manager, TestCase,
)

ROOT_PATH = os.path.abspath(os.path.dirname(__file__) + '../../../')
FIXTURES_PATH = os.path.join(ROOT_PATH, config.get('testing.fixtures_file'))


def setup_package():
    # Called by nosetests to setup the test suite
    fixtures_manager.load(FIXTURES_PATH,
                          models_package='ocelot.services.datastores')