massage unifi
This commit is contained in:
parent
d710d2c621
commit
f48bfa1193
2 changed files with 7 additions and 2 deletions
|
@ -143,6 +143,11 @@ def connection_handler(session, request, verify, as_is_reply=False):
|
||||||
try:
|
try:
|
||||||
get = s.send(r, verify=v)
|
get = s.send(r, verify=v)
|
||||||
if get.status_code == 401:
|
if get.status_code == 401:
|
||||||
|
if 'NoSiteContext' in str(get.content):
|
||||||
|
logger.info('Your Site is incorrect for %s', r.url)
|
||||||
|
elif 'LoginRequired' in str(get.content):
|
||||||
|
logger.info('Your login credentials are incorrect for %s', r.url)
|
||||||
|
else:
|
||||||
logger.info('Your api key is incorrect for %s', r.url)
|
logger.info('Your api key is incorrect for %s', r.url)
|
||||||
elif get.status_code == 404:
|
elif get.status_code == 404:
|
||||||
logger.info('This url doesnt even resolve: %s', r.url)
|
logger.info('This url doesnt even resolve: %s', r.url)
|
||||||
|
|
|
@ -24,7 +24,7 @@ class UniFiAPI(object):
|
||||||
req = self.session.prepare_request(Request('POST', self.server.url + endpoint, json=pre_cookies))
|
req = self.session.prepare_request(Request('POST', self.server.url + endpoint, json=pre_cookies))
|
||||||
post = connection_handler(self.session, req, self.server.verify_ssl, as_is_reply=True)
|
post = connection_handler(self.session, req, self.server.verify_ssl, as_is_reply=True)
|
||||||
|
|
||||||
if not post.cookies.get('unifises'):
|
if not post or not post.cookies.get('unifises'):
|
||||||
return
|
return
|
||||||
|
|
||||||
cookies = {'unifises': post.cookies.get('unifises')}
|
cookies = {'unifises': post.cookies.get('unifises')}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue