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() from clint.textui import puts, colored pformat = "%-25s = %s" puts('') for section in opts.sections: puts(colored.green("[%s]" % section)) for key, apconf_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 #apconf_value = apconf_value if apconf_value else '-' value = apconf_value or default_value value = unicode(value).encode('utf8') try: puts(pformat % ( keycolor, value)) except Exception as e: raise e puts('')
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) #import ipdb;ipdb.set_trace() 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, apconf_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 apconf_value = apconf_value if apconf_value else repr(apconf_value) puts(pformat % ( keycolor, clint_encode(value), colored.white(clint_encode(apconf_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])))