# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import sys
import os
import re
import urllib.request
import subprocess
from argparse import ArgumentParser
import traceback
-from html.parser import HTMLParser
+import html
from distutils.version import LooseVersion
import logging
import copy
from . import common
from . import metadata
-from .common import VCSException, FDroidException
-from .metadata import MetaDataException
+from .exception import VCSException, FDroidException, MetaDataException
# Check for a new version by looking at a document retrieved via HTTP.
m = re.search(codeex, page)
if not m:
raise FDroidException("No RE match for version code")
- vercode = m.group(1)
+ vercode = m.group(1).strip()
version = "??"
if len(urlver) > 0:
return (None, msg)
-def check_repotrunk(app, branch=None):
+def check_repotrunk(app):
try:
if app.RepoType == 'srclib':
req = urllib.request.Request(url, None, headers)
try:
resp = urllib.request.urlopen(req, None, 20)
- page = resp.read()
+ page = resp.read().decode()
except urllib.error.HTTPError as e:
return (None, str(e.code))
except Exception as e:
m = re.search('itemprop="softwareVersion">[ ]*([^<]+)[ ]*</div>', page)
if m:
- html_parser = HTMLParser()
- version = html_parser.unescape(m.group(1))
+ version = html.unescape(m.group(1))
if version == 'Varies with device':
return (None, 'Device-variable version, cannot use this method')
return commitmsg
-def checkupdates_app(app, first=True):
+def checkupdates_app(app):
# If a change is made, commitmsg should be set to a description of it.
# Only if this is set will changes be written back to the metadata.
elif vercode == app.CurrentVersionCode:
logging.info("...up to date")
else:
+ logging.debug("...updating - old vercode={0}, new vercode={1}".format(
+ app.CurrentVersionCode, vercode))
app.CurrentVersion = version
app.CurrentVersionCode = str(int(vercode))
updating = True
gotcur = False
latest = None
for build in app.builds:
- if int(build.vercode) >= int(app.CurrentVersionCode):
+ if int(build.versionCode) >= int(app.CurrentVersionCode):
gotcur = True
- if not latest or int(build.vercode) > int(latest.vercode):
+ if not latest or int(build.versionCode) > int(latest.versionCode):
latest = build
- if int(latest.vercode) > int(app.CurrentVersionCode):
+ if int(latest.versionCode) > int(app.CurrentVersionCode):
logging.info("Refusing to auto update, since the latest build is newer")
if not gotcur:
newbuild = copy.deepcopy(latest)
newbuild.disable = False
- newbuild.vercode = app.CurrentVersionCode
- newbuild.version = app.CurrentVersion + suffix
- logging.info("...auto-generating build for " + newbuild.version)
- commit = pattern.replace('%v', newbuild.version)
- commit = commit.replace('%c', newbuild.vercode)
+ newbuild.versionCode = app.CurrentVersionCode
+ newbuild.versionName = app.CurrentVersion + suffix
+ logging.info("...auto-generating build for " + newbuild.versionName)
+ commit = pattern.replace('%v', newbuild.versionName)
+ commit = commit.replace('%c', newbuild.versionCode)
newbuild.commit = commit
app.builds.append(newbuild)
name = common.getappname(app)
gitcmd.extend(['--author', config['auto_author']])
gitcmd.extend(["--", metadatapath])
if subprocess.call(gitcmd) != 0:
- logging.error("Git commit failed")
- sys.exit(1)
+ raise FDroidException("Git commit failed")
config = None
apps = common.read_app_args(options.appid, allapps, False)
if options.gplay:
- for app in apps:
+ for appid, app in apps.items():
version, reason = check_gplay(app)
if version is None:
if reason == '404':
logging.info("Processing " + appid + '...')
- checkupdates_app(app)
+ try:
+ checkupdates_app(app)
+ except Exception as e:
+ logging.error("...checkupdate failed for {0} : {1}".format(appid, e))
logging.info("Finished.")