本文整理汇总了Python中DAS.utils.logger.PrintManager.error方法的典型用法代码示例。如果您正苦于以下问题:Python PrintManager.error方法的具体用法?Python PrintManager.error怎么用?Python PrintManager.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DAS.utils.logger.PrintManager
的用法示例。
在下文中一共展示了PrintManager.error方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_error
# 需要导入模块: from DAS.utils.logger import PrintManager [as 别名]
# 或者: from DAS.utils.logger.PrintManager import error [as 别名]
def test_error(self):
"Test logger error method"
old_stdout = sys.stdout
logger = PrintManager(self.name) # verbose is irrelevant
sys.stdout = StringIO()
logger.error('test')
result = sys.stdout.getvalue()
expect = 'ERROR %s:%s test\n' % (self.name, funcname())
self.assertEqual(expect, result)
sys.stdout = old_stdout
示例2: Test
# 需要导入模块: from DAS.utils.logger import PrintManager [as 别名]
# 或者: from DAS.utils.logger.PrintManager import error [as 别名]
class Test(object):
"""
This is a test task that prints a message (supplied in kwargs) to stdout.
It will randomly sometimes raise exceptions (5%), spawn subtasks (4%) or
disable resubmission of itself (1%).
"""
task_title = "Test task"
task_options = [{"name":"message", "type":"string",
"default":"hello world", "help":"Message to print"}]
def __init__(self, **kwargs):
self.logger = PrintManager('Test', kwargs.get('verbose', 0))
self.name = kwargs['name']
self.message = kwargs['message']
self.index = kwargs['index']
def __call__(self):
self.logger.info('%s from index=%s' % (self.message, self.index))
result = {}
effect = random.random()
if effect > 0.99:
self.logger.info('..disabling resubmission')
result['resubmit'] = False
elif effect > 0.95:
task = {'name':'spawn-of-%s' % self.index,
'classname':'Test',
'interval': random.randint(1,30),
'kwargs':{'message':'spawn-of-%s' % self.message}}
effect2 = random.random()
if effect2 > 0.50:
task['only_once'] = True
self.logger.info('..spawning run-once task')
elif effect2 > 0.25:
task['max_runs'] = random.randint(1, 5)
self.logger.info(\
'..spawning task to run %s times' % task['max_runs'])
else:
task['only_before'] = time.time() + random.randint(1, 120)
self.logger.info(\
'..spawning task to run until %s' % task['only_before'])
result['new_tasks'] = [task]
elif effect > 0.90:
self.logger.error('..raising an exception')
raise
return result