diff --git a/CHANGELOG.md b/CHANGELOG.md index 93351f17..df8c9e1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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:** @@ -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:** diff --git a/Dockerfile b/Dockerfile index 8c84f9c3..e635b17f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Dockerfile.arm b/Dockerfile.arm index 8f126177..da5c42a3 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -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 \ No newline at end of file +VOLUME /config diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 98e5ff9c..4ae6d4d4 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -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 \ No newline at end of file +VOLUME /config diff --git a/varken/__init__.py b/varken/__init__.py index 7bdf0478..4877873e 100644 --- a/varken/__init__.py +++ b/varken/__init__.py @@ -1,2 +1,2 @@ -VERSION = "1.6.5" +VERSION = "1.6.6" BRANCH = 'master' diff --git a/varken/helpers.py b/varken/helpers.py index 459b51b9..723f39dc 100644 --- a/varken/helpers.py +++ b/varken/helpers.py @@ -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() @@ -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) @@ -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): @@ -143,7 +143,12 @@ 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: @@ -151,17 +156,16 @@ def connection_handler(session, request, verify, as_is_reply=False): 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 diff --git a/varken/unifi.py b/varken/unifi.py index dcb2c505..ad829e21 100644 --- a/varken/unifi.py +++ b/varken/unifi.py @@ -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')} @@ -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):