當前位置: 首頁>>代碼示例>>Python>>正文


Python logging.disable方法代碼示例

本文整理匯總了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()) 
開發者ID:vertical-knowledge,項目名稱:ripozo,代碼行數:21,代碼來源:adapters.py

示例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 
開發者ID:vertical-knowledge,項目名稱:ripozo,代碼行數:18,代碼來源:restmixins.py

示例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) 
開發者ID:vertical-knowledge,項目名稱:ripozo,代碼行數:22,代碼來源:end_to_end.py

示例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 
開發者ID:MarcelloLins,項目名稱:ServerlessCrawler-VancouverRealState,代碼行數:21,代碼來源:test_soup.py

示例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,
        ) 
開發者ID:liampauling,項目名稱:flumine,代碼行數:21,代碼來源:test_trade.py

示例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'] ] 
開發者ID:swiftgist,項目名稱:lrbd,代碼行數:22,代碼來源:test_luns.py

示例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) 
開發者ID:project-koku,項目名稱:koku,代碼行數:23,代碼來源:tests_middleware.py

示例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)) 
開發者ID:project-koku,項目名稱:koku,代碼行數:25,代碼來源:test_azure_report_processor.py

示例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) 
開發者ID:project-koku,項目名稱:koku,代碼行數:27,代碼來源:test_tasks.py

示例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) 
開發者ID:project-koku,項目名稱:koku,代碼行數:26,代碼來源:test_tasks.py

示例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) 
開發者ID:rhtyd,項目名稱:ipmisim,代碼行數:28,代碼來源:ipmisim.py

示例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) 
開發者ID:deis,項目名稱:controller,代碼行數:8,代碼來源:__init__.py

示例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 
開發者ID:PUNCH-Cyber,項目名稱:stoq,代碼行數:5,代碼來源:test_core.py

示例14: tearDown

# 需要導入模塊: import logging [as 別名]
# 或者: from logging import disable [as 別名]
def tearDown(self) -> None:
        logging.disable(logging.NOTSET) 
開發者ID:PUNCH-Cyber,項目名稱:stoq,代碼行數:4,代碼來源:test_core.py

示例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) 
開發者ID:PUNCH-Cyber,項目名稱:stoq,代碼行數:17,代碼來源:test_core.py


注:本文中的logging.disable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。