本文整理匯總了Python中pycurl.HTTPAUTH_DIGEST屬性的典型用法代碼示例。如果您正苦於以下問題:Python pycurl.HTTPAUTH_DIGEST屬性的具體用法?Python pycurl.HTTPAUTH_DIGEST怎麽用?Python pycurl.HTTPAUTH_DIGEST使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類pycurl
的用法示例。
在下文中一共展示了pycurl.HTTPAUTH_DIGEST屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import HTTPAUTH_DIGEST [as 別名]
def __init__(self, hass, config):
"""Construct a thread listening for events."""
self.hass = hass
for device_cfg in config:
url = URL_TEMPLATE.format(
protocol=device_cfg.get("protocol"),
host=device_cfg.get("host"),
port=device_cfg.get("port"),
events=device_cfg.get("events")
)
channels = device_cfg.get("channels")
channels_dict = {}
if channels is not None:
for channel in channels:
channels_dict[channel.get("number")] = channel.get("name")
device = DahuaDevice(self, hass, device_cfg.get("name"), url, channels_dict)
self.Devices.append(device)
CurlObj = pycurl.Curl()
device.CurlObj = CurlObj
CurlObj.setopt(pycurl.URL, url)
CurlObj.setopt(pycurl.CONNECTTIMEOUT, 30)
CurlObj.setopt(pycurl.TCP_KEEPALIVE, 1)
CurlObj.setopt(pycurl.TCP_KEEPIDLE, 30)
CurlObj.setopt(pycurl.TCP_KEEPINTVL, 15)
CurlObj.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
CurlObj.setopt(pycurl.USERPWD, "%s:%s" % (device_cfg.get("user"), device_cfg.get("password")))
CurlObj.setopt(pycurl.WRITEFUNCTION, device.OnReceive)
self.CurlMultiObj.add_handle(CurlObj)
self.NumCurlObjs += 1
_LOGGER.debug("Added Dahua device at: %s", url)
threading.Thread.__init__(self)
self.stopped = threading.Event()
示例2: perform
# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import HTTPAUTH_DIGEST [as 別名]
def perform(self):
self.__performHead=""
self.__performBody=""
conn=pycurl.Curl()
conn.setopt(pycurl.SSL_VERIFYPEER,False)
conn.setopt(pycurl.SSL_VERIFYHOST,1)
conn.setopt(pycurl.URL,self.completeUrl)
if self.__method or self.__userpass:
if self.__method=="basic":
conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_BASIC)
elif self.__method=="ntlm":
conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_NTLM)
elif self.__method=="digest":
conn.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_DIGEST)
conn.setopt(pycurl.USERPWD, self.__userpass)
if self.__timeout:
conn.setopt(pycurl.CONNECTTIMEOUT, self.__timeout)
conn.setopt(pycurl.NOSIGNAL, 1)
if self.__totaltimeout:
conn.setopt(pycurl.TIMEOUT, self.__totaltimeout)
conn.setopt(pycurl.NOSIGNAL, 1)
conn.setopt(pycurl.WRITEFUNCTION, self.body_callback)
conn.setopt(pycurl.HEADERFUNCTION, self.header_callback)
if self.__proxy!=None:
conn.setopt(pycurl.PROXY,self.__proxy)
if self.__headers.has_key("Proxy-Connection"):
del self.__headers["Proxy-Connection"]
conn.setopt(pycurl.HTTPHEADER,self.__getHeaders())
if self.method=="POST":
conn.setopt(pycurl.POSTFIELDS,self.__postdata)
conn.perform()
rp=Response()
rp.parseResponse(self.__performHead)
rp.addContent(self.__performBody)
self.response=rp
######### ESTE conjunto de funciones no es necesario para el uso habitual de la clase