当前位置: 首页>>代码示例>>Python>>正文


Python Session.params方法代码示例

本文整理汇总了Python中requests.Session.params方法的典型用法代码示例。如果您正苦于以下问题:Python Session.params方法的具体用法?Python Session.params怎么用?Python Session.params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在requests.Session的用法示例。


在下文中一共展示了Session.params方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_session

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import params [as 别名]
    def _create_session(self):
        method = self.auth_params['method']
        session = Session()
        session.headers['User-Agent'] = self.user_agent
        if method != 'oauth2-resourceowner':
            session.params = {'api_key': self.auth_params['api_key']}
        if self.json:
            session.headers['Accept'] = ACCEPT_HEADERS['json']

        Connection.__setattr__(self, 'session', session)
开发者ID:MediaMath,项目名称:t1-python,代码行数:12,代码来源:connection.py

示例2: __init__

# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import params [as 别名]
    def __init__(self,
                 hostname,
                 username,
                 password,
                 instance_name,
                 port,
                 use_ssl,
                 utc_delta,
                 proxy,
                 encrypt,
                 verify=True):
        """
        :param hostname: The hostname (or fully qualified domain name) of the ArcGIS Server.
        :type hostname: str

        :param username: The username used to log on as an administrative user to the ArcGIS Server.
        :type username: str

        :param password: The password for the administrative account used to login to the ArcGIS Server.
        :type password: str

        :param instance_name: The name of the ArcGIS Server instance.
        :type instance_name: str

        :param port: The port that the ArcGIS Server is operating on. If communication directly with an ArcGIS Server
        instance, you can ignore this setting and use the default.  If accesssing the ArcGIS Server REST Admin API
        through the ArcGIS Web Adaptor, enter the port the service is running on here.

        :param use_ssl: If True, instructs the REST Admin proxy to communicate with the ArcGIS Server REST Admin API
        via SSL/TLS.
        :type use_ssl: bool

        :param utc_delta: The time difference between UTC and the ArcGIS Server instance.  This is used to calculate
        when the admin token has expired, as Esri foolishly return this value as local server time, making calculation
        of its expiry impossible unless you know what time zone the server is also in.
        :type utc_delta: datetime.timedelta

        :param proxy: An addess of a proxy server to use for interacting with ArcGIS Server, if required.
        :type proxy: str

        :param encrypt: If set to True, uses public key crypto to encrypt communication with the ArcGIS
        Server instance.  Setting this to False disables public key crypto.  When communicating over SSL, this
        parameter is ignored, as SSL will already encrypt the traffic.
        :type encrypt: bool

        :param verify: Is set to True (default), which causes SSL certificates to be verified.  Can be set to false
        to disable verification, or set to the path of a CA_BUNDLE file, or to a directory with certifcates of a
        trusted certificate authority, to use for validating certificates.
        :type encrypt: bool or str
        """

        self._pdata = {
            "username": username
        }

        protocol = "https" if use_ssl else "http"

        # setup the requests session
        proxies = { protocol: proxy } if proxy else {}
        s = Session()
        s.verify = verify
        s.params = { "f": "json" }
        s.proxies = proxies

        # call super constructor with session and instance URL
        super().__init__(s, get_instance_url_base(protocol, hostname, port, instance_name))

        # Resolve the generate token endpoint from /arcgis/rest/info
        generate_token_url = None
        ags_info = self.get_server_info()

        if "authInfo" in ags_info and "isTokenBasedSecurity" in ags_info["authInfo"]:
            # token auth in use, setup auto-auth on requests on the session
            generate_token_url = ags_info["authInfo"]["tokenServicesUrl"]

            self._session.auth = _RestAdminAuth(
                username,
                password,
                generate_token_url,
                utc_delta=utc_delta,
                get_public_key_url=None if encrypt == False or use_ssl == True else self._url_full + "/publicKey",
                proxies=proxies,
                client="referer" if "/sharing" in generate_token_url else "requestip",
                referer=self._url_full if "/sharing" in generate_token_url else None,
                verify=verify
            )
开发者ID:DavidWhittingham,项目名称:agsadmin,代码行数:88,代码来源:_admin_base.py


注:本文中的requests.Session.params方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。