本文整理汇总了Python中socorro.lib.ConfigurationManager.newConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigurationManager.newConfiguration方法的具体用法?Python ConfigurationManager.newConfiguration怎么用?Python ConfigurationManager.newConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socorro.lib.ConfigurationManager
的用法示例。
在下文中一共展示了ConfigurationManager.newConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAcceptConfigFile
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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)
示例2: setupConfig
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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)
示例3: setup_module
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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
示例4: setup_module
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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
示例5: setup_module
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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()
示例6: main
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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)
示例7: setup_module
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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
示例8: setup_module
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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
示例9: testAcceptAutoCommandLineHelp
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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)
示例10: setUp
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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()
示例11: testAcceptUserCommandLineHelp
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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)
示例12: testAcceptCommandLine
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
def testAcceptCommandLine(self):
opts = []
args = {}
opts.append(('c','chickensoup',False,False,'help for the ailing'))
opts.append(('r','rabbit', True, '', 'rabbits are bunnies'))
args['configurationOptionsList'] = opts
sys.argv.append('-c')
sys.argv.append('--rabbit=bunny')
conf = CM.newConfiguration(**args)
assert('chickensoup' in conf)
assert('rabbit' in conf)
assert('bunny' == conf.rabbit)
示例13: testAcceptTypePriority
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
def testAcceptTypePriority(self):
'''Assure that commandline beats config file beats environment beats defaults'''
copt = [('c', 'config', True, self.configTstPath, "the test config file"),('r','rabbit', True, 'bambi', 'rabbits are bunnies')]
copt.append(('b','badger',True,'gentle','some badgers are gentle'))
copt.append(('z','zeta', True, 'zebra', 'zebras ooze'))
os.environ['badger'] = 'bloody'
os.environ['zeta'] = 'zymurgy'
sys.argv.append('--rabbit=kangaroo')
conf = CM.newConfiguration(automaticHelp=False,configurationOptionsList=copt,optionNameForConfigFile = 'config', configurationFileRequired = True)
assert('kangaroo' == conf.rabbit) # command line beats config file
assert('this badger=awful' == conf.badger) # config file beats environment
assert('zymurgy' == conf.zeta)
示例14: setUp
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
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()
示例15: testAcceptEnvironment
# 需要导入模块: from socorro.lib import ConfigurationManager [as 别名]
# 或者: from socorro.lib.ConfigurationManager import newConfiguration [as 别名]
def testAcceptEnvironment(self):
opts = []
args = {}
opts.append(('c','chickensoup',False,False,'help for the ailing'))
opts.append(('r','rabbit', True, '', 'rabbits are bunnies'))
args['configurationOptionsList'] = opts
os.environ['chickensoup']=''
os.environ['r'] = 'bunny-rabbit'
conf = CM.newConfiguration(**args)
assert('chickensoup' in conf)
assert('rabbit' in conf)
assert('bunny-rabbit' == conf.rabbit)