Exemplo n.º 1
0
    def handle_noargs(self, **options):
        # Inspired by Postfix's "postconf -n".
        from django.conf import settings

        # Because settings are imported lazily, we need to explicitly load them.
        settings._setup()

        user_settings = module_to_dict(settings._wrapped)

        opts = Options()
        pformat = "%-25s = %s"
        puts('')
        for section in opts.sections:
            puts(colored.green("[%s]" % section))
            for key, kaio_value in opts.items(section):
                keycolor = colored.magenta(key)
                if key in user_settings:
                    keycolor = colored.blue(key)

                default_value = opts.options[key].default_value
                value = kaio_value or default_value

                if sys.version_info[0] < 3:
                    value = unicode(value).encode('utf8')
                else:
                    value = str(value)

                try:
                    puts(pformat % (keycolor, value))
                except Exception as e:
                    raise e
            puts('')
Exemplo n.º 2
0
    def handle_noargs(self, **options):
        # Inspired by Postfix's "postconf -n".
        from django.conf import settings, global_settings

        # Because settings are imported lazily, we need to explicitly load them.
        settings._setup()

        user_settings = module_to_dict(settings._wrapped)
        default_settings = module_to_dict(global_settings)

        opts = Options()
        from clint.textui import puts, colored
        pformat = "%30s: %-30s %-30s %-30s"
        puts('')
        puts(pformat % (
            colored.white('Option'),
            colored.cyan('APP Value'),
            colored.cyan('INI Value'),
            colored.green('APP Default')))
        puts('')
        for section in opts.sections:
            puts(pformat % (colored.green("[%s]" % section), '', '', ''))
            for key, kaio_value in opts.items(section):
                keycolor = colored.magenta(key)
                if key in user_settings:
                    value = colored.green(user_settings[key])
                    keycolor = colored.blue(key)
                else:
                    value = colored.green(opts.options[key].get_value_or_default())

                default_value = opts.options[key].default_value
                kaio_value = kaio_value if kaio_value else repr(kaio_value)

                puts(pformat % (
                    keycolor,
                    clint_encode(value),
                    colored.white(clint_encode(kaio_value)),
                    clint_encode(default_value)))

            puts('')

        puts(colored.white("No configurables directamente en INI (estáticos o compuestos por otros):"))
        puts()

        not_configured = set(user_settings.keys()) - set(opts.keys())
        #not_configured = not_configured - set([
            #'INSTALLED_APPS',
            #'MIDDLEWARE_CLASSES',
            #'CONTEXT_PROCESSORS',
            #])
        pformat = "%30s: %-50s"
        puts(pformat % (
            colored.white('Option'),
            colored.cyan('Value')))
        for key in sorted(not_configured):
            if key not in default_settings:
                puts(pformat % (colored.blue(key),
                    user_settings[key]))
                    #'###'))
            elif user_settings[key] != default_settings[key]:
                puts(pformat % (
                    colored.blue(key),
                    colored.green(user_settings[key])))
Exemplo n.º 3
0
# -*- coding: utf-8 -*-

import logging
from kaio import Options
from functools import partial

SUPPORTED_BROKER_TYPES = ['redis', 'rabbitmq']
DEFAULT_BROKER_TYPE = 'redis'
DEFAULT_BROKER_URL = 'django://'  # used if cannot setup redis or rabbitmq

opts = Options()
get = partial(opts.get, section='Celery')

log = logging.getLogger(__name__)


class CeleryMixin(object):
    """Celery APSL Custom mixin"""

    CELERY_DISABLE_RATE_LIMITS = True
    CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'

    def _redis_available(self):
        try:
            import redis
        except ImportError:
            return False

        if not self.REDIS_PORT or not self.REDIS_HOST:
            return False