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


Python HTTPConnection.debuglevel方法代碼示例

本文整理匯總了Python中http.client.HTTPConnection.debuglevel方法的典型用法代碼示例。如果您正苦於以下問題:Python HTTPConnection.debuglevel方法的具體用法?Python HTTPConnection.debuglevel怎麽用?Python HTTPConnection.debuglevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在http.client.HTTPConnection的用法示例。


在下文中一共展示了HTTPConnection.debuglevel方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: enable_debug_requests

# 需要導入模塊: from http.client import HTTPConnection [as 別名]
# 或者: from http.client.HTTPConnection import debuglevel [as 別名]
def enable_debug_requests():
    # Enabling debugging at http.client level (requests->urllib3->http.client)
    # you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
    # the only thing missing will be the response.body which is not logged.
    from http.client import HTTPConnection
    import logging

    HTTPConnection.debuglevel = 1
    logger.setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True


# 去掉注釋,開啟調試模式
# enable_debug_requests() 
開發者ID:pandalibin,項目名稱:backtrader-cn,代碼行數:18,代碼來源:sina.py

示例2: setup_logger

# 需要導入模塊: from http.client import HTTPConnection [as 別名]
# 或者: from http.client.HTTPConnection import debuglevel [as 別名]
def setup_logger(log_level):
    if log_level == 'DEBUG':
        format = '%(asctime)s %(hostname)s %(name)s[%(process)d] %(levelname)s %(message)s'
        from http.client import HTTPConnection
        HTTPConnection.debuglevel = 1
        requests_log = logging.getLogger("requests.packages.urllib3")
        requests_log.setLevel(logging.DEBUG)
        requests_log.propagate = True

    else:
        format = click.style('anime', fg='green') + ': %(message)s'

    logger = logging.getLogger("anime_downloader")
    coloredlogs.install(level=log_level, fmt=format, logger=logger) 
開發者ID:vn-ki,項目名稱:anime-downloader,代碼行數:16,代碼來源:util.py

示例3: enable_request_debugging

# 需要導入模塊: from http.client import HTTPConnection [as 別名]
# 或者: from http.client.HTTPConnection import debuglevel [as 別名]
def enable_request_debugging():
        # Enabling debugging at http.client level (requests->urllib3->http.client)
        # you will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
        # the only thing missing will be the response.body which is not logged.
        try:  # for Python 3
            from http.client import HTTPConnection
        except ImportError:
            from requests.packages.urllib3.connectionpool import HTTPConnection
        HTTPConnection.debuglevel = 1

        logging.basicConfig()  # you need to initialize logging, otherwise you will not see anything from requests
        logging.getLogger().setLevel(logging.DEBUG)
        requests_log = logging.getLogger("requests.packages.urllib3")
        requests_log.setLevel(logging.DEBUG)
        requests_log.propagate = True 
開發者ID:faaez,項目名稱:capiq-python,代碼行數:17,代碼來源:capiq_client.py

示例4: __init__

# 需要導入模塊: from http.client import HTTPConnection [as 別名]
# 或者: from http.client.HTTPConnection import debuglevel [as 別名]
def __init__(self, endpoint=None, key=None, secret=None, token=None, username=None, password=None, timeout=5.0, ssl_verify=True, headers=None, debug=False):
        self.endpoint = endpoint or os.environ.get('ALERTA_ENDPOINT', self.DEFAULT_ENDPOINT)

        if debug:
            HTTPConnection.debuglevel = 1

        key = key or os.environ.get('ALERTA_API_KEY', '')
        self.http = HTTPClient(self.endpoint, key, secret, token, username, password, timeout, ssl_verify, headers, debug)

    # Alerts 
開發者ID:alerta,項目名稱:python-alerta-client,代碼行數:12,代碼來源:api.py

示例5: _init_logging

# 需要導入模塊: from http.client import HTTPConnection [as 別名]
# 或者: from http.client.HTTPConnection import debuglevel [as 別名]
def _init_logging():
    HTTPConnection.debuglevel = 1
    logging.basicConfig(level=logging.DEBUG,
                        format='%(levelname)5s - %(name)s -  %(message)s')
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True 
開發者ID:cloudfoundry-community,項目名稱:cf-python-client,代碼行數:9,代碼來源:config_test.py

示例6: main

# 需要導入模塊: from http.client import HTTPConnection [as 別名]
# 或者: from http.client.HTTPConnection import debuglevel [as 別名]
def main():
    args = parse_args()

    if args.verbose:
        log.setLevel(logging.DEBUG)
        requests_log.setLevel(logging.DEBUG)
        HTTPConnection.debuglevel = 2
        requests_log.propagate = True

    # Safety checks
    if args.no_branch and not args.YELPSOA_DIR:
        log.error(
            "You must specify --yelpsoa-configs-dir to work on if you use the --local option"
        )
        return False

    if args.ticket:
        if not args.jira_creds:
            raise ValueError("No JIRA creds specified")
        # Only import the jira module if we need too
        from jira.client import JIRA  # noqa: F401
    else:
        JIRA = None

    report = get_report_from_splunk(
        args.splunk_creds, args.splunk_app, args.csv_report, args.criteria_filter
    )

    tmpdir = tempdir()  # Create a tmp dir even if we are not using it

    working_dir = args.YELPSOA_DIR
    if working_dir is None:
        # Working in a temporary directory
        working_dir = os.path.join("rightsizer", tmpdir.name)
        clone_in(working_dir)

    with cwd(working_dir):
        if args.bulk or args.no_branch:
            log.info("Running in bulk mode")
            bulk_rightsize(
                report, args.create_reviews, args.publish_reviews, not args.no_branch
            )
        else:
            individual_rightsize(
                report,
                args.ticket,
                args.jira_creds,
                args.create_reviews,
                args.publish_reviews,
                JIRA,
            )

    tmpdir.cleanup()  # Cleanup any tmpdire used 
開發者ID:Yelp,項目名稱:paasta,代碼行數:55,代碼來源:paasta_update_soa_memcpu.py


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