def getStatus(self, param, value=""):
if self.whichCam() == "gpcontrol":
try:
req=urllib.request.urlopen("http://10.5.5.9/gp/gpControl/status", timeout=5)
data = req.read()
encoding = req.info().get_content_charset('utf-8')
json_data = json.loads(data.decode(encoding))
return json_data[param][value]
except (HTTPError, URLError) as error:
return ""
print("Error code:" + str(error.code) + "\nMake sure the connection to the WiFi camera is still active.")
except timeout:
return ""
print("HTTP Timeout\nMake sure the connection to the WiFi camera is still active.")
else:
response = urllib.request.urlopen("http://10.5.5.9/camera/sx?t=" + self.getPassword(), timeout=5).read()
response_hex = str(bytes.decode(base64.b16encode(response), 'utf-8'))
return str(response_hex[param[0]:param[1]])
评论列表
文章目录