Exemplo n.º 1
0
def main(args=sys.argv):

    parser = argparse.ArgumentParser()
    parser.add_argument('-f', dest='conffile', default='development.ini')
    subparsers = parser.add_subparsers(title="action")

    sp_import = subparsers.add_parser('import', help='import existing mailbox')
    sp_import.set_defaults(func=import_email)
    sp_import.add_argument('-f',
                           dest='format',
                           choices=['mbox', 'maildir'],
                           default='mbox')
    sp_import.add_argument('-p', dest='import_path')
    sp_import.add_argument('-e', dest='email')

    sp_setup_storage = subparsers.add_parser(
        'setup', help='initialize the storage engine')
    sp_setup_storage.set_defaults(func=setup_storage)

    sp_create_user = subparsers.add_parser('create_user',
                                           help='Create a new user')
    sp_create_user.set_defaults(func=create_user)
    sp_create_user.add_argument('-e', dest='email', help='user email')
    sp_create_user.add_argument('-p', dest='password', help='password')
    sp_create_user.add_argument('-f',
                                dest='first_name',
                                help='user first name')
    sp_create_user.add_argument('-l', dest='last_name', help='user last name')

    sp_shell = subparsers.add_parser('shell')
    sp_shell.set_defaults(func=shell)

    kwargs = parser.parse_args(args[1:])
    kwargs = vars(kwargs)

    config_uri = kwargs.pop('conffile')
    func = kwargs.pop('func')

    setup_logging(config_uri)
    settings = get_appsettings(config_uri, u'main')
    # do not declare routes and others useless includes
    del settings['pyramid.includes']

    kwargs['settings'] = settings

    config = Configurator(settings=settings)

    if func != setup_storage:  # Don't try to configure if it's not setup up
        include_caliop_core(config)
    else:
        for file in aslist(settings['caliopen.config']):
            name, path = file.split(':', 1)
            Configuration.load(path, name)
    config.end()
    func(**kwargs)
Exemplo n.º 2
0
def main(args=sys.argv):

    parser = argparse.ArgumentParser()
    parser.add_argument('-f', dest='conffile', default='development.ini')
    subparsers = parser.add_subparsers(title="action")

    sp_import = subparsers.add_parser('import', help='import existing mailbox')
    sp_import.set_defaults(func=import_email)
    sp_import.add_argument('-f', dest='format', choices=['mbox', 'maildir'],
                           default='mbox')
    sp_import.add_argument('-p', dest='import_path')
    sp_import.add_argument('-e', dest='email')

    sp_setup_storage = subparsers.add_parser('setup',
        help='initialize the storage engine')
    sp_setup_storage.set_defaults(func=setup_storage)

    sp_create_user = subparsers.add_parser('create_user',
        help='Create a new user')
    sp_create_user.set_defaults(func=create_user)
    sp_create_user.add_argument('-e', dest='email', help='user email')
    sp_create_user.add_argument('-p', dest='password', help='password')
    sp_create_user.add_argument('-f', dest='first_name',
                                help='user first name')
    sp_create_user.add_argument('-l', dest='last_name',
                                help='user last name')

    sp_shell = subparsers.add_parser('shell')
    sp_shell.set_defaults(func=shell)

    kwargs = parser.parse_args(args[1:])
    kwargs = vars(kwargs)

    config_uri = kwargs.pop('conffile')
    func = kwargs.pop('func')

    setup_logging(config_uri)
    settings = get_appsettings(config_uri, u'main')
    # do not declare routes and others useless includes
    del settings['pyramid.includes']

    kwargs['settings'] = settings

    config = Configurator(settings=settings)

    if func != setup_storage:  # Don't try to configure if it's not setup up
        include_caliop_core(config)
    else:
        for file in aslist(settings['caliopen.config']):
            name, path = file.split(':', 1)
            Configuration.load(path, name)
    config.end()
    func(**kwargs)
Exemplo n.º 3
0
#!/usr/bin/env python
import sys
from cqlengine import connection
from caliopen.config import Configuration

Configuration.load('./tmp/conf.yaml', 'global')
connection.setup(['127.0.0.1:9160'])

from caliopen.smtp.agent import DeliveryAgent

if __name__ == '__main__':
    agent = DeliveryAgent()
    data = open(sys.argv[1]).read()
    messages = agent.process(data)
Exemplo n.º 4
0
from __future__ import unicode_literals

import os

from caliopen.config import Configuration
from caliopen.core.config import includeme

# Core objects do need implmeentations to be registered
# If no implementation is registered, an exception is raised.

# This is required prior to any `caliopen.core` object inclusion

# This is a (ugly) way to have everything executed
# before the core objects imports

# Load config file
pwd = os.path.dirname(os.path.realpath(__file__))
DEFAULT_CONFIG_FILE = '%s/../../../caliopen.yaml' % pwd
Configuration.load(os.environ.get('CALIOPEN_CONFIG', DEFAULT_CONFIG_FILE),
                   'global')

# register implmentations
includeme()
Exemplo n.º 5
0
#!/usr/bin/env python
import sys
from cqlengine import connection
from caliopen.config import Configuration

Configuration.load('./tmp/conf.yaml', 'global')
connection.setup(['127.0.0.1:9160'])

from caliopen.smtp.agent import DeliveryAgent


if __name__ == '__main__':
    agent = DeliveryAgent()
    data = open(sys.argv[1]).read()
    messages = agent.process(data)
Exemplo n.º 6
0
from __future__ import unicode_literals

import os

from caliopen.config import Configuration
from caliopen.core.config import includeme


# Core objects do need implmeentations to be registered
# If no implementation is registered, an exception is raised.

# This is required prior to any `caliopen.core` object inclusion

# This is a (ugly) way to have everything executed
# before the core objects imports

# Load config file
pwd = os.path.dirname(os.path.realpath(__file__))
DEFAULT_CONFIG_FILE = '%s/../../../caliopen.yaml' % pwd
Configuration.load(os.environ.get('CALIOPEN_CONFIG', DEFAULT_CONFIG_FILE),
        'global')

# register implmentations
includeme()
Exemplo n.º 7
0
import logging
from gsmtpd import LMTPServer
from cqlengine import connection

from caliopen.config import Configuration

Configuration.load('caliopen.yaml', 'global')
connection.setup(['127.0.0.1:9160'])

from caliopen.core.config import includeme
includeme(None)

log = logging.getLogger(__name__)
from caliopen.smtp.agent import DeliveryAgent


class LmtpServer(LMTPServer):
    def process_message(self, peer, mailfrom, rcpttos, data):
        agent = DeliveryAgent()
        messages = agent.process(mailfrom, rcpttos, data)
        log.info('Deliver of %d messages' % len(messages))
        return None


if __name__ == '__main__':
    s = LmtpServer(("127.0.0.1", 4000))
    s.serve_forever()