本文整理汇总了Python中socorro.lib.ConfigurationManager类的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager类的具体用法?Python ConfigurationManager怎么用?Python ConfigurationManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigurationManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
"""Create a configuration context and a database connection. """
self.config = ConfigurationManager.newConfiguration(
configurationModule=commonconfig, applicationName="PostgreSQL Tests"
)
try:
self.database = db.Database(self.config)
except (AttributeError, KeyError):
raise
self.connection = self.database.connection()
开发者ID:phb,项目名称:socorro,代码行数:12,代码来源:unittestbase.py
示例2: setup_module
import unittest
import socorro.database.database as db
import psycopg2
import psycopg2.extensions
import logging
import threading
from socorro.unittest.testlib.loggerForTest import TestingLogger
import socorro.unittest.testlib.util as tutil
from createDBforTest import *
import socorro.lib.util as util
import socorro.lib.ConfigurationManager as cm
import dbTestconfig as testConfig
config = cm.newConfiguration(configurationModule = testConfig, applicationName='Testing Psycopghelper')
def setup_module():
tutil.nosePrintModule(__file__)
"""
Assume that psycopg2 works, then all we need to do is assure ourselves
that our simplistic wrap around a returned array is correct
"""
class TestMultiCursor(psycopg2.extensions.cursor):
def __init__(self,numCols = 4, numRows=2, **kwargs):
self.result = []
for i in range(numRows):
aRow = []
for j in range(numCols):
aRow.append('Row %d, Column %d' %(i,j))
开发者ID:Meghashyamt,项目名称:socorro,代码行数:30,代码来源:testDatabase.py
示例3:
import sys
import logging
import logging.handlers
try:
import config.bugzillaconfig as configModule
except ImportError:
import bugzillaconfig as configModule
import socorro.lib.ConfigurationManager as configurationManager
import socorro.cron.bugzilla as bug
import socorro.lib.util as sutil
try:
config = configurationManager.newConfiguration(configurationModule=configModule, applicationName="Bugzilla Associations 0.1")
except configurationManager.NotAnOptionError, x:
print >>sys.stderr, x
print >>sys.stderr, "for usage, try --help"
sys.exit()
logger = logging.getLogger("bugzilla")
logger.setLevel(logging.DEBUG)
sutil.setupLoggingHandlers(logger, config)
sutil.echoConfig(logger, config)
try:
bug.record_associations(config)
finally:
logger.info("done.")
开发者ID:AlinT,项目名称:socorro,代码行数:30,代码来源:startBugzilla.py
示例4:
import sys
import logging
import logging.handlers
try:
import config.duplicatesconfig as configModule
except ImportError:
import duplicatesconfig as configModule
import socorro.lib.ConfigurationManager as configurationManager
import socorro.cron.duplicates as duplicates
import socorro.lib.util as sutil
try:
config = configurationManager.newConfiguration(configurationModule=configModule, applicationName="Duplicate Detector 0.1")
except configurationManager.NotAnOptionError, x:
print >>sys.stderr, x
print >>sys.stderr, "for usage, try --help"
sys.exit()
logger = logging.getLogger("duplicates")
logger.setLevel(logging.DEBUG)
sutil.setupLoggingHandlers(logger, config)
sutil.echoConfig(logger, config)
try:
duplicates.find_duplicates(config)
finally:
logger.info("done.")
开发者ID:Earth4,项目名称:socorro,代码行数:30,代码来源:startDuplicates.py
示例5:
import logging
import logging.handlers
import sys
try:
import config.fixbrokendumpsconfig as configModule
except ImportError:
import fixbrokendumpsconfig as configModule
import socorro.lib.ConfigurationManager as configurationManager
import socorro.cron.fixBrokenDumps as fixBrokenDumps
import socorro.lib.util as sutil
try:
config = configurationManager.newConfiguration(configurationModule=configModule, applicationName="Fix Broken Dumps")
except configurationManager.NotAnOptionError, x:
print >>sys.stderr, x
print >>sys.stderr, "for usage, try --help"
sys.exit(1)
logger = logging.getLogger("fix_broken_dumps")
logger.setLevel(logging.DEBUG)
sutil.setupLoggingHandlers(logger, config)
sutil.echoConfig(logger, config)
try:
last_date_processed = fixBrokenDumps.fix(config, logger, config.brokenFirefoxLinuxQuery, config.brokenFirefoxLinuxFixer)
last_date_processed = fixBrokenDumps.fix(config, logger, config.brokenFennecQuery, config.brokenFennecFixer)
开发者ID:AlinT,项目名称:socorro,代码行数:29,代码来源:startFixBrokenDumps.py
示例6: __init__
def __init__(self,*args,**kwargs):
"""
Passes appropriate kwargs to Config, pays local attention to these keys:
updateInterval: default: '0' format: 'dd:hh:mm:ss', leading parts optional. Must be >= 0 seconds.
updateFunction: default: noop(). Takes self as argument. Behavior: Updates default values in argument
reEvaluateFunction: default: noop(). Takes self as argument. Behavior: Mutates values in argument
signalNumber: default: SIGALRM (14). If 0, then signals will not be handled.
Instances that share the same signalNumber will all be update()-ed at every signal.
self.internal.updateFunction may be set after construction if desired: Avoids double-work at construction
self.internal.reEvalutateFunction may be set after construction if desired, but this is not recommended.
"""
skwargs = dict([(x,kwargs[x]) for x in socorro_config.getDefaultedConfigOptions().keys() if x in kwargs])
for i in range(len(args)):
skwargs[socorro_config.namedConfigOptions[i]] = args[i]
super(DynamicConfig,self).__init__(**skwargs)
self.internal.updateFunction = kwargs.get('updateFunction',noop)
self.internal.reEvaluateFunction = kwargs.get('reEvaluateFunction',noop)
self.internal.signalNumber = kwargs.get('signalNumber',14)
self.internal.nextUpdate = None
updateInterval = kwargs.get('updateInterval','0:0:0:0')
self.internal.updateDelta = socorro_config.timeDeltaConverter(updateInterval)
if self.internal.updateDelta:
if self.internal.updateDelta < datetime.timedelta(0):
raise ValueError("updateInterval must be non-negative, but %s"%self.internal.updateDelta)
self.internal.nextUpdate = utc_now() + self.internal.updateDelta
# finally: make sure we are current
if self.internal.signalNumber:
priorSignal = signal.signal(self.internal.signalNumber,DynamicConfig.handleAlarm)
self.doUpdate()
DynamicConfig.instances[id(self)] = self
开发者ID:Earth4,项目名称:socorro,代码行数:32,代码来源:dynamicConfigurationManager.py
示例7: testAcceptConfigFile
def testAcceptConfigFile(self):
# Test failure with good config file, unknown option in that file
try:
copt = [('c', 'config', True, self.configTstPath, "the test config file")]
CM.newConfiguration(configurationOptionsList=copt,optionNameForConfigFile = 'config', configurationFileRequired = True)
assert(False)
except CM.NotAnOptionError, e:
assert(True)
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:8,代码来源:testConfigurationManager.py
示例8: getProcessingWindow
def getProcessingWindow(configContext,tableName, productVersionRestriction,cursor,logger, **kwargs):
"""
ProcessingWindow is a single time window over which to aggregate materialized view data.
Returns (startWindow,deltaWindow,endWindow) using this heuristic:
kwargs beats configContext which beats latest table row
if two among startWindow, endWindow, deltaWindow in config or kwargs: they are used.
if all three: assert startWindow + deltaWindow == endWindow
Backward compatibility: if processingDay is present and windowXxx are not:
startWindow = midnight of given day, deltaWindow = timedelta(days=1)
else: try to read window_end and window_size from the given table
if one is available from config/kwargs it beats the same (or calculated) one from the table
On inconsistency or failure, logs the problem and aborts
BEWARE: You can get inconsitency by having one item in config and the other two in kwargs: BEWARE
"""
config = {}
config.update(configContext)
config.update(kwargs)
startWindow = config.get('startWindow')
if type(startWindow) is str:
startWindow = cm.dateTimeConverter(startWindow)
deltaWindow = config.get('deltaWindow')
if type(deltaWindow) is str:
deltaWindow = cm.timeDeltaConverter(deltaWindow)
endWindow = config.get('endWindow')
if type(endWindow) is str:
endWindow = cm.dateTimeConverter(endWindow)
processingDay = config.get('processingDay')
if type(processingDay) is str:
processingDay = cm.dateTimeConverter(processingDay)
try:
if startWindow or deltaWindow or endWindow:
if startWindow and endWindow and deltaWindow:
assert startWindow + deltaWindow == endWindow,"inconsistent: %s + %s != %s"%(startWindow,deltaWindow,endWindow)
elif startWindow and endWindow:
deltaWindow = endWindow - startWindow
elif startWindow and deltaWindow:
endWindow = startWindow + deltaWindow
elif deltaWindow and endWindow:
startWindow = endWindow - deltaWindow
else:
assert not (startWindow or deltaWindow or endWindow), "insufficient: Need two of window ...Start: %s, ...Delta: %s, ...End:%s"%(startWindow,deltaWindow,endWindow)
elif processingDay:
dayt = datetime.datetime.fromtimestamp(time.mktime(processingDay.timetuple()))
startWindow = dayt.replace(hour=0,minute=0,second=0,microsecond=0)
assert startWindow == dayt,'processingDay must be some midnight, but was %s'%dayt
deltaWindow = datetime.timedelta(days=1)
endWindow = startWindow + deltaWindow
else: # no params: try table
startWindow,deltaWindow = getLastWindowAndSizeFromTable(cursor,tableName, productVersionRestriction,logger)
if startWindow:
endWindow = startWindow+deltaWindow
return (startWindow,deltaWindow,endWindow)
except:
lib_util.reportExceptionAndAbort(logger)
开发者ID:AlinT,项目名称:socorro,代码行数:55,代码来源:util.py
示例9: newConfiguration
def newConfiguration(**kwargs):
""" This used as an alternate constructor for class Config so that applications can
be lax in defining all the required paramters in the right order.
"""
kw = socorro_config.getDefaultedConfigOptions()
kw.update(kwargs)
return DynamicConfig(**kw)
开发者ID:Earth4,项目名称:socorro,代码行数:7,代码来源:dynamicConfigurationManager.py
示例10: main
def main():
logger = logging.getLogger("topcrashes_summary")
logger.setLevel(logging.WARNING)
stderrLog = logging.StreamHandler()
stderrLog.setLevel(logging.WARNING)
stderrLogFormatter = logging.Formatter('%(asctime)s %(levelname)s - %(message)s')
stderrLog.setFormatter(stderrLogFormatter)
logger.addHandler(stderrLog)
kwargs = {}
for i in sys.argv[1:]:
if i.startswith('-h') or i.startswith('--he'):
help()
sys.exit(0)
j = i
if i.startswith('-'):
j = i.lstrip('-')
if '=' in j:
name,value = (s.strip() for s in j.split('='))
kwargs[name] = value
else:
print >> sys.stderr,"Ignoring unkown argument '%s'"%(i)
sys.argv = sys.argv[:1]
config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Create Database')
config.update(kwargs)
testDB = TestDB()
testDB.removeDB(config,logger)
testDB.createDB(config,logger)
开发者ID:AlinT,项目名称:socorro,代码行数:29,代码来源:createSchema.py
示例11: setup_module
def setup_module():
global me
if me:
return
# else initialize
# print "MODULE setup"
me = Me()
me.markingTemplate = "MARK %s: %s"
me.startMark = 'start'
me.endMark = 'end'
me.testDB = TestDB()
me.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing Monitor')
myDir = os.path.split(__file__)[0]
if not myDir: myDir = '.'
replDict = {'testDir':'%s'%myDir}
for i in me.config:
try:
me.config[i] = me.config.get(i)%(replDict)
except:
pass
knownTests = [x for x in dir(TestMonitor) if x.startswith('test')]
me.logWasExtracted = {}
for t in knownTests:
me.logWasExtracted[t] = False
me.logger = monitor.logger
me.logger.setLevel(logging.DEBUG)
me.logFilePathname = me.config.logFilePathname
logfileDir = os.path.split(me.config.logFilePathname)[0]
try:
os.makedirs(logfileDir)
except OSError,x:
if errno.EEXIST != x.errno: raise
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:33,代码来源:testMonitor.py
示例12: setup_module
def setup_module():
global me
if me:
return
me = Me()
me.config = cfgManager.newConfiguration(configurationModule=testConfig,
applicationName='Testing ftpscraper')
myDir = os.path.split(__file__)[0]
if not myDir:
myDir = '.'
replDict = {'testDir': '%s' % myDir}
for i in me.config:
try:
me.config[i] = me.config.get(i) % (replDict)
except:
pass
me.logFilePathname = me.config.logFilePathname
if not me.logFilePathname:
me.logFilePathname = 'logs/ftpscraper_test.log'
logFileDir = os.path.split(me.logFilePathname)[0]
try:
os.makedirs(logFileDir)
except OSError, x:
if errno.EEXIST == x.errno:
pass
else:
raise
开发者ID:Meghashyamt,项目名称:socorro,代码行数:27,代码来源:testFtpScraper.py
示例13: setup_module
def setup_module():
global me
if me:
return
me = Me()
tutil.nosePrintModule(__file__)
me.config = configurationManager.newConfiguration(
configurationModule=testConfig, applicationName="Testing Postgresql Utils"
)
myDir = os.path.split(__file__)[0]
if not myDir:
myDir = "."
replDict = {"testDir": "%s" % myDir}
for i in me.config:
try:
me.config[i] = me.config.get(i) % (replDict)
except:
pass
me.logFilePathname = me.config.logFilePathname
if not me.logFilePathname:
me.logFilePathname = "logs/db_test.log"
logFileDir = os.path.split(me.logFilePathname)[0]
try:
os.makedirs(logFileDir)
except OSError, x:
if errno.EEXIST == x.errno:
pass
else:
raise
开发者ID:trinaldi,项目名称:socorro,代码行数:29,代码来源:testSchema.py
示例14: setup_module
def setup_module():
global me
if me:
return
me = Me()
tutil.nosePrintModule(__file__)
# config gets messed up by some tests. Use this one during module setup and teardown
me.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing Postgresql Utils')
myDir = os.path.split(__file__)[0]
if not myDir: myDir = '.'
replDict = {'testDir':'%s'%myDir}
for i in me.config:
try:
me.config[i] = me.config.get(i)%(replDict)
except:
pass
me.logFilePathname = me.config.logFilePathname
if not me.logFilePathname:
me.logFilePathname = 'logs/db_test.log'
logFileDir = os.path.split(me.logFilePathname)[0]
try:
os.makedirs(logFileDir)
except OSError,x:
if errno.EEXIST == x.errno: pass
else: raise
开发者ID:Meghashyamt,项目名称:socorro,代码行数:25,代码来源:testPostgresql.py
示例15: setup_module
def setup_module():
global me
if me:
return
me = Me()
tutil.nosePrintModule(__file__)
me.testDB = TestDB()
me.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='TestingCachedIdAccess')
myDir = os.path.split(__file__)[0]
if not myDir: myDir = '.'
replDict = {'testDir':'%s'%myDir}
for i in me.config:
try:
me.config[i] = me.config.get(i)%(replDict)
except:
pass
cia.logger.setLevel(logging.DEBUG)
me.logFilePathname = me.config.logFilePathname
logfileDir = os.path.split(me.config.logFilePathname)[0]
try:
os.makedirs(logfileDir)
except OSError,x:
if errno.EEXIST != x.errno: raise
f = open(me.config.logFilePathname,'w')
f.close()
开发者ID:AlinT,项目名称:socorro,代码行数:25,代码来源:testCachedIdAccess.py
示例16: setupConfig
def setupConfig():
try:
return configurationManager.newConfiguration(configurationModule=config, applicationName="Migrate Process Type")
except configurationManager.NotAnOptionError, x:
print >>sys.stderr, x
print >>sys.stderr, "for usage, try --help"
sys.exit(1)
开发者ID:Earth4,项目名称:socorro,代码行数:7,代码来源:migrateProcessType.py
示例17: fixupContextByProcessingDay
def fixupContextByProcessingDay(self,context):
pday = context.get('processingDay')
if pday:
logger.info("Adjusting startDate and deltaDate per processingDay %s",pday)
pday = cm.dateTimeConverter(pday)
startDate = datetime.datetime.fromtimestamp(time.mktime(pday.timetuple()))
startDate.replace(hour=0,minute=0,second=0,microsecond=0)
context['startDate'] = startDate
context['deltaDate'] = datetime.timedelta(days=1)
context['startWindw'] = startDate
开发者ID:Meghashyamt,项目名称:socorro,代码行数:10,代码来源:topCrashesByUrl.py
示例18: testAcceptAutoCommandLineHelp
def testAcceptAutoCommandLineHelp(self):
opts = []
args = {}
args['automaticHelp'] = True
args['configurationOptionsList'] = opts
hh = HelpHandler()
args['helpHandler'] = hh.handleHelp
sys.argv.append('--help')
conf = CM.newConfiguration(**args)
assert("--help" in hh.data)
assert("print this list" in hh.data)
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:11,代码来源:testConfigurationManager.py
示例19: setUp
def setUp(self):
global me
# config gets messed up by some tests. Use this one by preference
self.config = configurationManager.newConfiguration(configurationModule = testConfig, applicationName='Testing Postgresql Utils')
for i in self.config:
try:
self.config[i] = self.config.get(i)%(replDict)
except:
pass
self.connection = psycopg2.connect(me.dsn)
self.testDB = TestDB()
开发者ID:Earth4,项目名称:socorro,代码行数:11,代码来源:testPostgresql.py
示例20: testAcceptUserCommandLineHelp
def testAcceptUserCommandLineHelp(self):
opts = [('h','help',False,False,'another help')]
args = {}
args['automaticHelp'] = False
args['configurationOptionsList'] = opts
hh = HelpHandler()
args['helpHandler'] = hh.handleHelp
sys.argv.append('--help')
conf = CM.newConfiguration(**args)
assert("--help" in hh.data)
assert("another help" in hh.data)
开发者ID:boudewijnrempt,项目名称:HyvesDesktop,代码行数:11,代码来源:testConfigurationManager.py
注:本文中的socorro.lib.ConfigurationManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论