本文整理汇总了Python中logging.disable方法的典型用法代码示例。如果您正苦于以下问题:Python logging.disable方法的具体用法?Python logging.disable怎么用?Python logging.disable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logging
的用法示例。
在下文中一共展示了logging.disable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def setUp(self):
logging.disable('DEBUG')
class MyManager(InMemoryManager):
_fields = ('id', 'first', 'second',)
_field_validators = {
'first': fields.IntegerField('first', required=True),
'second': fields.IntegerField('second', required=True)
}
class MyClass(CRUDL):
resource_name = 'myresource'
manager = MyManager()
self.resource_class = MyClass
self.manager = MyClass.manager
for i in six.moves.range(100):
self.manager.objects[i] = dict(id=i, first=1, second=2)
self.resource = MyClass.retrieve_list(RequestContainer())
示例2: setUp
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def setUp(self):
logging.disable('DEBUG')
class MyManager(InMemoryManager):
_fields = ('id', 'first', 'second',)
_field_validators = {
'first': fields.IntegerField('first', required=True),
'second': fields.IntegerField('second', required=True)
}
class MyClass(CRUDL):
manager = MyManager()
resource_name = 'myresource'
self.resource_class = MyClass
self.manager = MyClass.manager
示例3: setUp
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def setUp(self):
logging.disable('DEBUG')
class MyManager(InMemoryManager):
_fields = ('id', 'first', 'second',)
_field_validators = {
'first': fields.IntegerField('first', required=True),
'second': fields.IntegerField('second', required=True)
}
class MyClass(CRUDL):
resource_name = 'myresource'
manager = MyManager()
self.resource_class = MyClass
self.manager = MyClass.manager
for i in six.moves.range(100):
self.manager.objects[i] = dict(id=i, first=1, second=2)
self.dispatcher = FakeDispatcher()
self.dispatcher.register_adapters(SirenAdapter, HalAdapter, BoringJSONAdapter)
示例4: test_ascii_in_unicode_out
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_ascii_in_unicode_out(self):
# ASCII input is converted to Unicode. The original_encoding
# attribute is set to 'utf-8', a superset of ASCII.
chardet = bs4.dammit.chardet_dammit
logging.disable(logging.WARNING)
try:
def noop(str):
return None
# Disable chardet, which will realize that the ASCII is ASCII.
bs4.dammit.chardet_dammit = noop
ascii = b"<foo>a</foo>"
soup_from_ascii = self.soup(ascii)
unicode_output = soup_from_ascii.decode()
self.assertTrue(isinstance(unicode_output, unicode))
self.assertEqual(unicode_output, self.document_for(ascii.decode()))
self.assertEqual(soup_from_ascii.original_encoding.lower(), "utf-8")
finally:
logging.disable(logging.NOTSET)
bs4.dammit.chardet_dammit = chardet
示例5: setUp
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def setUp(self) -> None:
logging.disable(logging.CRITICAL)
self.mock_strategy = mock.Mock()
self.mock_fill_kill = mock.Mock()
self.mock_offset = mock.Mock()
self.mock_green = mock.Mock()
self.mock_stop = mock.Mock()
self.notes = collections.OrderedDict({"trigger": 123})
self.trade = Trade(
"1.234",
567,
1.0,
self.mock_strategy,
self.notes,
self.mock_fill_kill,
self.mock_offset,
self.mock_green,
self.mock_stop,
)
示例6: test_cmd_for_rbd
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_cmd_for_rbd(self):
Runtime.config['backstore'] = "rbd"
class mock_Luns(Luns):
def _find(self):
pass
class mock_LunAssignment(object):
def assign(self, target, tpg, image, lun):
pass
def assigned(self, target, image):
pass
logging.disable(logging.DEBUG)
_la = mock_LunAssignment()
self.l = mock_Luns(_la)
print self.l.unassigned
assert self.l.unassigned == [ ['targetcli', '/iscsi/iqn.xyz/tpg1/luns', 'create', '/backstores/rbd/rbd-archive'] ]
示例7: test_race_condition_user_caching
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_race_condition_user_caching(self):
"""Test case for caching where another request may create the user in a race condition."""
mock_request = self.request
middleware = IdentityHeaderMiddleware()
self.assertEquals(MD.USER_CACHE.maxsize, 5) # Confirm that the size of the user cache has changed
self.assertEquals(MD.USER_CACHE.currsize, 0) # Confirm that the user cache is empty
middleware.process_request(mock_request)
self.assertEquals(MD.USER_CACHE.currsize, 1)
self.assertTrue(hasattr(mock_request, "user"))
customer = Customer.objects.get(account_id=self.customer.account_id)
self.assertIsNotNone(customer)
user = User.objects.get(username=self.user_data["username"])
self.assertEquals(MD.USER_CACHE.currsize, 1)
self.assertIsNotNone(user)
IdentityHeaderMiddleware.create_user(
username=self.user_data["username"], # pylint: disable=W0212
email=self.user_data["email"],
customer=customer,
request=mock_request,
)
self.assertEquals(MD.USER_CACHE.currsize, 1)
示例8: test_azure_process
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_azure_process(self):
"""Test the processing of an uncompressed Azure file."""
counts = {}
report_db = self.accessor
report_schema = report_db.report_schema
for table_name in self.report_tables:
table = getattr(report_schema, table_name)
with schema_context(self.schema):
count = table.objects.count()
counts[table_name] = count
logging.disable(logging.NOTSET) # We are currently disabling all logging below CRITICAL in masu/__init__.py
with self.assertLogs("masu.processor.azure.azure_report_processor", level="INFO") as logger:
self.processor.process()
self.assertIn("INFO:masu.processor.azure.azure_report_processor", logger.output[0])
self.assertIn("costreport_a243c6f2-199f-4074-9a2c-40e671cf1584.csv", logger.output[0])
for table_name in self.report_tables:
table = getattr(report_schema, table_name)
with schema_context(self.schema):
count = table.objects.count()
self.assertTrue(count > counts[table_name])
self.assertFalse(os.path.exists(self.test_report))
示例9: test_disk_status_logging
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_disk_status_logging(self, fake_downloader):
"""Test task for logging when temp directory exists."""
logging.disable(logging.NOTSET)
os.makedirs(Config.TMP_DIR, exist_ok=True)
account = fake_arn(service="iam", generate_account_id=True)
expected = "Available disk space"
with self.assertLogs("masu.processor._tasks.download", level="INFO") as logger:
_get_report_files(
Mock(),
customer_name=self.fake.word(),
authentication=account,
provider_type=Provider.PROVIDER_AWS,
report_month=DateHelper().today,
provider_uuid=self.aws_provider_uuid,
billing_source=self.fake.word(),
cache_key=self.fake.word(),
)
statement_found = False
for log in logger.output:
if expected in log:
statement_found = True
self.assertTrue(statement_found)
shutil.rmtree(Config.TMP_DIR, ignore_errors=True)
示例10: test_disk_status_logging_no_dir
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_disk_status_logging_no_dir(self, fake_downloader):
"""Test task for logging when temp directory does not exist."""
logging.disable(logging.NOTSET)
Config.PVC_DIR = "/this/path/does/not/exist"
account = fake_arn(service="iam", generate_account_id=True)
expected = "Unable to find" + f" available disk space. {Config.PVC_DIR} does not exist"
with self.assertLogs("masu.processor._tasks.download", level="INFO") as logger:
_get_report_files(
Mock(),
customer_name=self.fake.word(),
authentication=account,
provider_type=Provider.PROVIDER_AWS,
report_month=DateHelper().today,
provider_uuid=self.aws_provider_uuid,
billing_source=self.fake.word(),
cache_key=self.fake.word(),
)
statement_found = False
for log in logger.output:
if expected in log:
statement_found = True
self.assertTrue(statement_found)
示例11: main
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def main():
logging.disable(logging.NOTSET)
logger.setLevel(logging.INFO)
ch = logging.StreamHandler(sys.stdout)
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
port = 9001
if len(sys.argv) > 1:
port = int(sys.argv[1])
# Initialize context
ctx = IpmiServerContext()
try:
ThreadedIpmiServer.allow_reuse_address = True
server = ThreadedIpmiServer(('0.0.0.0', port), IpmiServer)
logger.info("Started IPMI Server on 0.0.0.0:" + str(port))
server.serve_forever()
except KeyboardInterrupt:
server.shutdown()
server.server_close()
sys.exit(0)
示例12: run_tests
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def run_tests(self, test_labels, extra_tests=None, **kwargs):
"""Run tests with all but critical log messages disabled."""
# hide any log messages less than critical
logging.disable(logging.ERROR)
return super(SilentDjangoTestSuiteRunner, self).run_tests(
test_labels, extra_tests, **kwargs)
示例13: setUp
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def setUp(self) -> None:
logging.disable(logging.CRITICAL)
self.generic_content = b'The quick brown fox' # type: ignore
示例14: tearDown
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def tearDown(self) -> None:
logging.disable(logging.NOTSET)
示例15: test_connector_exception
# 需要导入模块: import logging [as 别名]
# 或者: from logging import disable [as 别名]
def test_connector_exception(self):
s = Stoq(base_dir=utils.get_data_dir(), connectors=['dummy_connector'])
dummy_connector = s.load_plugin('dummy_connector')
dummy_connector.save = asynctest.create_autospec(
dummy_connector.save, side_effect=RuntimeError('Unexpected exception')
)
logging.disable(logging.NOTSET)
with self.assertLogs(level='ERROR') as cm:
await s.scan(self.generic_content)
self.assertTrue(
cm.output[0].startswith(
'ERROR:stoq:Failed to save results using dummy_connector'
)
)
logging.disable(logging.CRITICAL)