Use RawConfigParser instead of dict.viewitems
dict.viewitems breaks python 2.6 compatibility.
This commit is contained in:
parent
b1bb15d1f9
commit
b4ab702f10
@ -18,6 +18,7 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
from ConfigParser import RawConfigParser
|
||||||
from celery.signals import setup_logging
|
from celery.signals import setup_logging
|
||||||
|
|
||||||
from mediagoblin import app, mg_globals
|
from mediagoblin import app, mg_globals
|
||||||
@ -32,7 +33,7 @@ _log.setLevel(logging.DEBUG)
|
|||||||
_log.warning('Test')
|
_log.warning('Test')
|
||||||
|
|
||||||
|
|
||||||
def setup_logging_from_paste_ini(*args, **kw):
|
def setup_logging_from_paste_ini(loglevel, **kw):
|
||||||
if os.path.exists(os.path.abspath('paste_local.ini')):
|
if os.path.exists(os.path.abspath('paste_local.ini')):
|
||||||
logging_conf_file = 'paste_local.ini'
|
logging_conf_file = 'paste_local.ini'
|
||||||
else:
|
else:
|
||||||
@ -46,10 +47,13 @@ def setup_logging_from_paste_ini(*args, **kw):
|
|||||||
|
|
||||||
config = logging_conf
|
config = logging_conf
|
||||||
|
|
||||||
|
# Read raw config to avoid interpolation of formatting parameters
|
||||||
|
raw_config = RawConfigParser()
|
||||||
|
raw_config.readfp(open(logging_conf_file))
|
||||||
|
|
||||||
# Set up formatting
|
# Set up formatting
|
||||||
# Get the format string and circumvent configobj interpolation of the value
|
# Get the format string and circumvent configobj interpolation of the value
|
||||||
fmt = config['formatter_generic'].viewitems().__iter__()\
|
fmt = raw_config.get('formatter_generic', 'format')
|
||||||
.next()[1]
|
|
||||||
|
|
||||||
# Create the formatter
|
# Create the formatter
|
||||||
formatter = logging.Formatter(fmt)
|
formatter = logging.Formatter(fmt)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user