1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-14 11:00:10 +01:00

Merge branch 'fix_gplay_check' into 'master'

Fix gplay check

See merge request !333
This commit is contained in:
Hans-Christoph Steiner 2017-09-13 07:18:46 +00:00
commit a4a7b99760

View File

@ -25,7 +25,7 @@ import time
import subprocess import subprocess
from argparse import ArgumentParser from argparse import ArgumentParser
import traceback import traceback
from html.parser import HTMLParser import html
from distutils.version import LooseVersion from distutils.version import LooseVersion
import logging import logging
import copy import copy
@ -279,7 +279,7 @@ def check_gplay(app):
req = urllib.request.Request(url, None, headers) req = urllib.request.Request(url, None, headers)
try: try:
resp = urllib.request.urlopen(req, None, 20) resp = urllib.request.urlopen(req, None, 20)
page = resp.read() page = resp.read().decode()
except urllib.error.HTTPError as e: except urllib.error.HTTPError as e:
return (None, str(e.code)) return (None, str(e.code))
except Exception as e: except Exception as e:
@ -289,8 +289,7 @@ def check_gplay(app):
m = re.search('itemprop="softwareVersion">[ ]*([^<]+)[ ]*</div>', page) m = re.search('itemprop="softwareVersion">[ ]*([^<]+)[ ]*</div>', page)
if m: if m:
html_parser = HTMLParser() version = html.unescape(m.group(1))
version = html_parser.unescape(m.group(1))
if version == 'Varies with device': if version == 'Varies with device':
return (None, 'Device-variable version, cannot use this method') return (None, 'Device-variable version, cannot use this method')
@ -531,7 +530,7 @@ def main():
apps = common.read_app_args(options.appid, allapps, False) apps = common.read_app_args(options.appid, allapps, False)
if options.gplay: if options.gplay:
for app in apps: for appid, app in apps.items():
version, reason = check_gplay(app) version, reason = check_gplay(app)
if version is None: if version is None:
if reason == '404': if reason == '404':