mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
[checkupdates] Don't catch exceptions
Basically moves all code one level up.
This commit is contained in:
parent
a2db8f4a62
commit
6f7a1ecf01
2 changed files with 224 additions and 258 deletions
|
@ -48,8 +48,6 @@ def check_http(app):
|
||||||
ignoreversions = app.UpdateCheckIgnore
|
ignoreversions = app.UpdateCheckIgnore
|
||||||
ignoresearch = re.compile(ignoreversions).search if ignoreversions else None
|
ignoresearch = re.compile(ignoreversions).search if ignoreversions else None
|
||||||
|
|
||||||
try:
|
|
||||||
|
|
||||||
if not app.UpdateCheckData:
|
if not app.UpdateCheckData:
|
||||||
raise FDroidException('Missing Update Check Data')
|
raise FDroidException('Missing Update Check Data')
|
||||||
|
|
||||||
|
@ -94,21 +92,15 @@ def check_http(app):
|
||||||
return (None, ("Version {version} is ignored").format(version=version))
|
return (None, ("Version {version} is ignored").format(version=version))
|
||||||
else:
|
else:
|
||||||
return (version, vercode)
|
return (version, vercode)
|
||||||
except FDroidException:
|
|
||||||
msg = "Could not complete http check for app {0} due to unknown error: {1}".format(app.id, traceback.format_exc())
|
|
||||||
return (None, msg)
|
|
||||||
|
|
||||||
|
|
||||||
# Check for a new version by looking at the tags in the source repo.
|
|
||||||
# Whether this can be used reliably or not depends on
|
|
||||||
# the development procedures used by the project's developers. Use it with
|
|
||||||
# caution, because it's inappropriate for many projects.
|
|
||||||
# Returns (None, "a message") if this didn't work, or (version, vercode, tag) for
|
|
||||||
# the details of the current version.
|
|
||||||
def check_tags(app, pattern):
|
def check_tags(app, pattern):
|
||||||
|
"""Check for a new version by looking at the tags in the source repo.
|
||||||
|
|
||||||
try:
|
Whether this can be used reliably or not depends on
|
||||||
|
the development procedures used by the project's developers. Use it with
|
||||||
|
caution, because it's inappropriate for many projects.
|
||||||
|
"""
|
||||||
if app.RepoType == 'srclib':
|
if app.RepoType == 'srclib':
|
||||||
build_dir = Path('build/srclib') / app.Repo
|
build_dir = Path('build/srclib') / app.Repo
|
||||||
repotype = common.getsrclibvcs(app.Repo)
|
repotype = common.getsrclibvcs(app.Repo)
|
||||||
|
@ -228,24 +220,14 @@ def check_tags(app, pattern):
|
||||||
return (hver, hcode, htag)
|
return (hver, hcode, htag)
|
||||||
return (None, "Couldn't find any version information", None)
|
return (None, "Couldn't find any version information", None)
|
||||||
|
|
||||||
except VCSException as vcse:
|
|
||||||
msg = "VCS error while scanning app {0}: {1}".format(app.id, vcse)
|
|
||||||
return (None, msg, None)
|
|
||||||
except Exception:
|
|
||||||
msg = "Could not scan app {0} due to unknown error: {1}".format(app.id, traceback.format_exc())
|
|
||||||
return (None, msg, None)
|
|
||||||
|
|
||||||
|
|
||||||
# Check for a new version by looking at the AndroidManifest.xml at the HEAD
|
|
||||||
# of the source repo. Whether this can be used reliably or not depends on
|
|
||||||
# the development procedures used by the project's developers. Use it with
|
|
||||||
# caution, because it's inappropriate for many projects.
|
|
||||||
# Returns (None, "a message") if this didn't work, or (version, vercode) for
|
|
||||||
# the details of the current version.
|
|
||||||
def check_repomanifest(app, branch=None):
|
def check_repomanifest(app, branch=None):
|
||||||
|
"""Check for a new version by looking at the AndroidManifest.xml at the HEAD of the source repo.
|
||||||
|
|
||||||
try:
|
Whether this can be used reliably or not depends on
|
||||||
|
the development procedures used by the project's developers. Use it with
|
||||||
|
caution, because it's inappropriate for many projects.
|
||||||
|
"""
|
||||||
if app.RepoType == 'srclib':
|
if app.RepoType == 'srclib':
|
||||||
build_dir = Path('build/srclib') / app.Repo
|
build_dir = Path('build/srclib') / app.Repo
|
||||||
repotype = common.getsrclibvcs(app.Repo)
|
repotype = common.getsrclibvcs(app.Repo)
|
||||||
|
@ -295,17 +277,8 @@ def check_repomanifest(app, branch=None):
|
||||||
return (hver, hcode)
|
return (hver, hcode)
|
||||||
return (None, "Couldn't find any version information")
|
return (None, "Couldn't find any version information")
|
||||||
|
|
||||||
except VCSException as vcse:
|
|
||||||
msg = "VCS error while scanning app {0}: {1}".format(app.id, vcse)
|
|
||||||
return (None, msg)
|
|
||||||
except Exception:
|
|
||||||
msg = "Could not scan app {0} due to unknown error: {1}".format(app.id, traceback.format_exc())
|
|
||||||
return (None, msg)
|
|
||||||
|
|
||||||
|
|
||||||
def check_repotrunk(app):
|
def check_repotrunk(app):
|
||||||
|
|
||||||
try:
|
|
||||||
if app.RepoType == 'srclib':
|
if app.RepoType == 'srclib':
|
||||||
build_dir = Path('build/srclib') / app.Repo
|
build_dir = Path('build/srclib') / app.Repo
|
||||||
repotype = common.getsrclibvcs(app.Repo)
|
repotype = common.getsrclibvcs(app.Repo)
|
||||||
|
@ -323,12 +296,6 @@ def check_repotrunk(app):
|
||||||
|
|
||||||
ref = vcs.getref()
|
ref = vcs.getref()
|
||||||
return (ref, ref)
|
return (ref, ref)
|
||||||
except VCSException as vcse:
|
|
||||||
msg = "VCS error while scanning app {0}: {1}".format(app.id, vcse)
|
|
||||||
return (None, msg)
|
|
||||||
except Exception:
|
|
||||||
msg = "Could not scan app {0} due to unknown error: {1}".format(app.id, traceback.format_exc())
|
|
||||||
return (None, msg)
|
|
||||||
|
|
||||||
|
|
||||||
# Check for a new version by looking at the Google Play Store.
|
# Check for a new version by looking at the Google Play Store.
|
||||||
|
|
|
@ -186,9 +186,8 @@ class CheckupdatesTest(unittest.TestCase):
|
||||||
faked = scheme + '://fake.url/for/testing/scheme'
|
faked = scheme + '://fake.url/for/testing/scheme'
|
||||||
app.UpdateCheckData = faked + '|ignored|' + faked + '|ignored'
|
app.UpdateCheckData = faked + '|ignored|' + faked + '|ignored'
|
||||||
app.metadatapath = 'metadata/' + app.id + '.yml'
|
app.metadatapath = 'metadata/' + app.id + '.yml'
|
||||||
vername, vercode = fdroidserver.checkupdates.check_http(app)
|
with self.assertRaises(FDroidException):
|
||||||
self.assertIsNone(vername)
|
fdroidserver.checkupdates.check_http(app)
|
||||||
self.assertTrue(FDroidException.__name__ in vercode)
|
|
||||||
|
|
||||||
def test_check_http_ignore(self):
|
def test_check_http_ignore(self):
|
||||||
fdroidserver.checkupdates.options = mock.Mock()
|
fdroidserver.checkupdates.options = mock.Mock()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue