Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fixes bug 756105 - update to latest configman #607

Merged
merged 1 commit into from

2 participants

@twobraids
Owner

this latest version of configman changes the way that the application object works within the socorro generic_app module. This change should be invisible to anything except that module.

this change also includes some reformatting for consistency.

@peterbe peterbe commented on the diff
requirements/prod.txt
@@ -1,5 +1,5 @@
# configman moves too fast for pypi right now
-git+git://github.com/mozilla/configman@9c29f7830a4d1d6e1222fb80114f558f95d25e5c#egg=configman
+git+git://github.com/mozilla/configman@501365977c4321ca40f53e2f56cce6bded013dac#egg=configman
@peterbe Owner
peterbe added a note

we're going to need to figure out how to solve the problem with make virtualenv where this doesn't get upgraded even though the hash is different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@peterbe
Owner

r+

@twobraids twobraids merged commit 134ecd7 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 22, 2012
  1. @twobraids

    updated to latest configman

    twobraids authored
This page is out of date. Refresh to see the latest.
Showing with 78 additions and 55 deletions.
  1. +1 −1  requirements/prod.txt
  2. +77 −54 socorro/app/generic_app.py
View
2  requirements/prod.txt
@@ -1,5 +1,5 @@
# configman moves too fast for pypi right now
-git+git://github.com/mozilla/configman@9c29f7830a4d1d6e1222fb80114f558f95d25e5c#egg=configman
+git+git://github.com/mozilla/configman@501365977c4321ca40f53e2f56cce6bded013dac#egg=configman
@peterbe Owner
peterbe added a note

we're going to need to figure out how to solve the problem with make virtualenv where this doesn't get upgraded even though the hash is different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
configobj==4.7.2
hbase-thrift==0.20.4
isodate==0.4.7
View
131 socorro/app/generic_app.py
@@ -25,65 +25,83 @@ def __init__(self, config):
#--------------------------------------------------------------------------
def main(self): # pragma: no cover
"""derived classes must override this function with business logic"""
- raise NotImplementedError("A definition of 'main' in a derived class"
- "is required")
+ raise NotImplementedError(
+ "A definition of 'main' in a derived class is required"
+ )
#------------------------------------------------------------------------------
def logging_required_config(app_name):
lc = Namespace()
- lc.add_option('syslog_host',
- doc='syslog hostname',
- default='localhost')
- lc.add_option('syslog_port',
- doc='syslog port',
- default=514)
- lc.add_option('syslog_facility_string',
- doc='syslog facility string ("user", "local0", etc)',
- default='user')
- lc.add_option('syslog_line_format_string',
- doc='python logging system format for syslog entries',
- default='%s (pid {process}): '
- '{asctime} {levelname} - {threadName} - '
- '{message}' % app_name)
- lc.add_option('syslog_error_logging_level',
- doc='logging level for the log file (10 - DEBUG, 20 '
- '- INFO, 30 - WARNING, 40 - ERROR, 50 - CRITICAL)',
- default=40)
- lc.add_option('stderr_line_format_string',
- doc='python logging system format for logging to stderr',
- default='{asctime} {levelname} - {threadName} - '
- '{message}')
- lc.add_option('stderr_error_logging_level',
- doc='logging level for the logging to stderr (10 - '
- 'DEBUG, 20 - INFO, 30 - WARNING, 40 - ERROR, '
- '50 - CRITICAL)',
- default=10)
+ lc.add_option(
+ 'syslog_host',
+ doc='syslog hostname',
+ default='localhost'
+ )
+ lc.add_option(
+ 'syslog_port',
+ doc='syslog port',
+ default=514
+ )
+ lc.add_option(
+ 'syslog_facility_string',
+ doc='syslog facility string ("user", "local0", etc)',
+ default='user'
+ )
+ lc.add_option(
+ 'syslog_line_format_string',
+ doc='python logging system format for syslog entries',
+ default='%s (pid {process}): '
+ '{asctime} {levelname} - {threadName} - '
+ '{message}' % app_name
+ )
+ lc.add_option(
+ 'syslog_error_logging_level',
+ doc='logging level for the log file (10 - DEBUG, 20 '
+ '- INFO, 30 - WARNING, 40 - ERROR, 50 - CRITICAL)',
+ default=40
+ )
+ lc.add_option(
+ 'stderr_line_format_string',
+ doc='python logging system format for logging to stderr',
+ default='{asctime} {levelname} - {threadName} - '
+ '{message}'
+ )
+ lc.add_option(
+ 'stderr_error_logging_level',
+ doc='logging level for the logging to stderr (10 - '
+ 'DEBUG, 20 - INFO, 30 - WARNING, 40 - ERROR, '
+ '50 - CRITICAL)',
+ default=10
+ )
return lc
#------------------------------------------------------------------------------
-
def setup_logger(app_name, config, local_unused, args_unused):
logger = logging.getLogger(app_name)
logger.setLevel(logging.DEBUG)
stderr_log = logging.StreamHandler()
stderr_log.setLevel(config.stderr_error_logging_level)
stderr_log_formatter = logging.Formatter(
- _convert_format_string(config.stderr_line_format_string))
+ _convert_format_string(config.stderr_line_format_string)
+ )
stderr_log.setFormatter(stderr_log_formatter)
logger.addHandler(stderr_log)
syslog = logging.handlers.SysLogHandler(
- facility=config.syslog_facility_string)
+ facility=config.syslog_facility_string
+ )
syslog.setLevel(config.syslog_error_logging_level)
syslog_formatter = logging.Formatter(
- _convert_format_string(config.syslog_line_format_string))
+ _convert_format_string(config.syslog_line_format_string)
+ )
syslog.setFormatter(syslog_formatter)
logger.addHandler(syslog)
return logger
+#------------------------------------------------------------------------------
def _convert_format_string(s):
"""return '%(foo)s %(bar)s' if the input is '{foo} {bar}'"""
return re.sub('{(\w+)}', r'%(\1)s', s)
@@ -103,13 +121,13 @@ def main(initial_app, values_source_list=None):
# parameters. For a module to be acceptable, it must have a main
# function that accepts a DotDict derivative as its input parameter.
app_definition = Namespace()
- app_definition.admin = admin = Namespace()
- admin.add_option('application',
- doc='the fully qualified module or class of the '
- 'application',
- default=initial_app,
- from_string_converter=class_converter
- )
+ app_definition.add_option(
+ 'application',
+ doc='the fully qualified module or class of the '
+ 'application',
+ default=initial_app,
+ from_string_converter=class_converter
+ )
try:
app_name = initial_app.app_name # this will be used as the default
# b
@@ -118,19 +136,24 @@ def main(initial_app, values_source_list=None):
except AttributeError, x:
raise AppDetailMissingError(str(x))
- app_definition.add_aggregation('logger',
- functools.partial(setup_logger,
- app_name))
-
- definitions = (app_definition,
- logging_required_config(app_name))
-
- config_manager = ConfigurationManager(definitions,
- app_name=app_name,
- app_version=app_version,
- app_description=app_description,
- values_source_list=values_source_list,
- )
+ app_definition.add_aggregation(
+ 'logger',
+ functools.partial(setup_logger,
+ app_name)
+ )
+
+ definitions = (
+ app_definition,
+ logging_required_config(app_name)
+ )
+
+ config_manager = ConfigurationManager(
+ definitions,
+ app_name=app_name,
+ app_version=app_version,
+ app_description=app_description,
+ values_source_list=values_source_list,
+ )
with config_manager.context() as config:
config_manager.log_config(config.logger)
@@ -140,7 +163,7 @@ def main(initial_app, values_source_list=None):
# it might not always be that way. The user always has the ability
# to specify on the command line a new app class that will override
# 'initial_app'.
- app = config.admin.application
+ app = config.application
if isinstance(app, type):
# invocation of the app if the app_object was a class
Something went wrong with that request. Please try again.