json parse version string

This commit is contained in:
Michael Shamoon 2022-04-01 15:31:10 -07:00
parent 6dbebf4806
commit d02c7df75c

View File

@ -1,6 +1,6 @@
import json
import logging import logging
import os import os
import re
import tempfile import tempfile
import urllib import urllib
import uuid import uuid
@ -683,9 +683,11 @@ class RemoteVersionView(GenericAPIView):
+ "/paperless-ngx/main/src/paperless/version.py", + "/paperless-ngx/main/src/paperless/version.py",
) as response: ) as response:
remote = response.read().decode("utf-8") remote = response.read().decode("utf-8")
match = re.search(r"(\d+, \d+, \d+)", remote) try:
if match: remote_json = json.loads(remote)
remote_version = ".".join(match[0].split(", ")) remote_version = remote_json["tag_name"].replace("ngx-", "")
except ValueError:
logger.debug("An error occured parsing remote version json")
except urllib.error.URLError: except urllib.error.URLError:
logger.debug("An error occured checking for available updates") logger.debug("An error occured checking for available updates")