Skip to content

Commit

Permalink
Merge pull request #116 from Boerderij/develop
Browse files Browse the repository at this point in the history
v1.6.6 Merge
  • Loading branch information
samwiseg0 authored Mar 12, 2019
2 parents 06e8e88 + 58727c5 commit 8877b7b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 20 deletions.
21 changes: 17 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# Change Log

## [v1.6.5](https://github.com/Boerderij/Varken/tree/v1.6.5) (2019-03-11)
[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.6.4...v1.6.5)
## [v1.6.6](https://github.com/Boerderij/Varken/tree/v1.6.6) (2019-03-11)
[Full Changelog](https://github.com/Boerderij/Varken/compare/1.6.5...v1.6.6)

**Fixed bugs:**

- \[BUG\] TZDATA issue in docker images [\#112](https://github.com/Boerderij/Varken/issues/112)
- \[BUG\] Unifi job does not try again after failure [\#107](https://github.com/Boerderij/Varken/issues/107)
- \[BUG\] Catch ChunkError [\#106](https://github.com/Boerderij/Varken/issues/106)

**Merged pull requests:**

- v1.6.6 Merge [\#116](https://github.com/Boerderij/Varken/pull/116) ([samwiseg0](https://github.com/samwiseg0))

## [1.6.5](https://github.com/Boerderij/Varken/tree/1.6.5) (2019-03-11)
[Full Changelog](https://github.com/Boerderij/Varken/compare/v1.6.4...1.6.5)

**Implemented enhancements:**

Expand All @@ -19,8 +32,8 @@

- v1.6.5 Merge [\#115](https://github.com/Boerderij/Varken/pull/115) ([samwiseg0](https://github.com/samwiseg0))

## [1.6.4](https://github.com/Boerderij/Varken/tree/1.6.4) (2019-02-04)
[Full Changelog](https://github.com/Boerderij/Varken/compare/1.6.3...1.6.4)
## [v1.6.4](https://github.com/Boerderij/Varken/tree/v1.6.4) (2019-02-04)
[Full Changelog](https://github.com/Boerderij/Varken/compare/1.6.3...v1.6.4)

**Fixed bugs:**

Expand Down
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ COPY /varken /app/varken

COPY /data /app/data

RUN python3 -m pip install -r /app/requirements.txt
RUN apk add --no-cache tzdata && \
python3 -m pip install -r /app/requirements.txt

CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config

Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.arm
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ COPY /varken /app/varken

COPY /data /app/data

RUN python3 -m pip install -r /app/requirements.txt
RUN apk add --no-cache tzdata && \
python3 -m pip install -r /app/requirements.txt

CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config

VOLUME /config
VOLUME /config
5 changes: 3 additions & 2 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ COPY /varken /app/varken

COPY /data /app/data

RUN python3 -m pip install -r /app/requirements.txt
RUN apk add --no-cache tzdata && \
python3 -m pip install -r /app/requirements.txt

CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config

VOLUME /config
VOLUME /config
2 changes: 1 addition & 1 deletion varken/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
VERSION = "1.6.5"
VERSION = "1.6.6"
BRANCH = 'master'
18 changes: 11 additions & 7 deletions varken/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from json.decoder import JSONDecodeError
from os.path import abspath, join, basename, isdir
from urllib3.exceptions import InsecureRequestWarning
from requests.exceptions import InvalidSchema, SSLError, ConnectionError
from requests.exceptions import InvalidSchema, SSLError, ConnectionError, ChunkedEncodingError

logger = getLogger()

Expand Down Expand Up @@ -98,7 +98,7 @@ def download(self):
try:
remove(self.dbfile)
except FileNotFoundError:
self.logger.warn("Cannot remove GeoLite2 DB as it does not exsist!")
self.logger.warning("Cannot remove GeoLite2 DB as it does not exist!")

self.logger.debug("Opening GeoLite2 tar file : %s", tar_dbfile)

Expand All @@ -115,7 +115,7 @@ def download(self):
remove(tar_dbfile)
self.logger.debug('Removed the GeoLite2 DB TAR file.')
except FileNotFoundError:
self.logger.warn("Cannot remove GeoLite2 DB TAR file as it does not exsist!")
self.logger.warning("Cannot remove GeoLite2 DB TAR file as it does not exist!")


def hashit(string):
Expand Down Expand Up @@ -143,25 +143,29 @@ def connection_handler(session, request, verify, as_is_reply=False):
try:
get = s.send(r, verify=v)
if get.status_code == 401:
logger.info('Your api key is incorrect for %s', r.url)
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)
elif get.status_code == 404:
logger.info('This url doesnt even resolve: %s', r.url)
elif get.status_code == 200:
try:
return_json = get.json()
except JSONDecodeError:
logger.error('No JSON response. Response is: %s', get.text)

if air:
return get
except InvalidSchema:
logger.error("You added http(s):// in the config file. Don't do that.")

except SSLError as e:
logger.error('Either your host is unreachable or you have an SSL issue. : %s', e)

except ConnectionError as e:
logger.error('Cannot resolve the url/ip/port. Check connectivity. Error: %s', e)
except ChunkedEncodingError as e:
logger.error('Broken connection during request... oops? Error: %s', e)

return return_json

Expand Down
6 changes: 3 additions & 3 deletions varken/unifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_cookie(self):
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)

if not post.cookies.get('unifises'):
if not post or not post.cookies.get('unifises'):
return

cookies = {'unifises': post.cookies.get('unifises')}
Expand All @@ -37,8 +37,8 @@ def get_usg_stats(self):
get = connection_handler(self.session, req, self.server.verify_ssl)

if not get:
self.logger.error("Canceling Job get_usg_stats for unifi-%s", self.server.id)
return f"unifi-{self.server.id}-get_usg_stats"
self.logger.error("Disregarding Job get_usg_stats for unifi-%s", self.server.id)
return

devices = {device['name']: device for device in get['data']}
if devices.get(self.server.usg_name):
Expand Down

0 comments on commit 8877b7b

Please sign in to comment.