|
|
@ -31,7 +31,7 @@ def PTZData(d, root="PTZData"): |
|
|
|
def etree_to_list(t): |
|
|
|
d = [] |
|
|
|
k = t.tag.split('}')[-1] |
|
|
|
v = list(map(etree_to_dict, t.getchildren())) |
|
|
|
v = list(map(etree_to_dict, list(t))) |
|
|
|
if len(v) == 1: |
|
|
|
v = v[0] |
|
|
|
elif v and not isinstance(v[0], dict): |
|
|
@ -47,7 +47,7 @@ def etree_to_list(t): |
|
|
|
def etree_to_dict(t): |
|
|
|
d = {} |
|
|
|
k = t.tag.split('}')[-1] |
|
|
|
v = list(map(etree_to_dict, t.getchildren())) |
|
|
|
v = list(map(etree_to_dict, list(t))) |
|
|
|
if len(v) == 1: |
|
|
|
v = v[0] |
|
|
|
#elif v and not isinstance(v[0], dict): |
|
|
@ -127,20 +127,12 @@ class Camera: |
|
|
|
return {} |
|
|
|
|
|
|
|
def get(self, method): |
|
|
|
while True: |
|
|
|
try: |
|
|
|
return requests.get(self.url(method), auth=self.auth).text |
|
|
|
except requests.exceptions.ConnectionError: |
|
|
|
time.sleep(0.1) |
|
|
|
return requests.get(self.url(method), auth=self.auth).text |
|
|
|
|
|
|
|
def put(self, method, data): |
|
|
|
if isinstance(data, dict): |
|
|
|
data = PTZData(data) |
|
|
|
while True: |
|
|
|
try: |
|
|
|
return requests.put(self.url(method), data=data, auth=self.auth).text |
|
|
|
except requests.exceptions.ConnectionError: |
|
|
|
time.sleep(0.1) |
|
|
|
return requests.put(self.url(method), data=data, auth=self.auth).text |
|
|
|
|
|
|
|
def momentary(self, cmd, duration=None): |
|
|
|
if duration: |
|
|
|