Make use of FDroidException in the main fdroid script

This should improve the output shown when exceptions are found
This commit is contained in:
Daniel Martí 2014-07-03 13:59:36 +02:00
parent d9d5f30d7b
commit 73142c740b
2 changed files with 14 additions and 5 deletions

13
fdroid
View file

@ -21,6 +21,8 @@
import sys import sys
import logging import logging
from fdroidserver.common import FDroidException
commands = { commands = {
"build": "Build a package from source", "build": "Build a package from source",
"init": "Quickly start a new repository", "init": "Quickly start a new repository",
@ -83,14 +85,21 @@ def main():
del sys.argv[1] del sys.argv[1]
mod = __import__('fdroidserver.' + command, None, None, [command]) mod = __import__('fdroidserver.' + command, None, None, [command])
try: try:
mod.main() mod.main()
except Exception, e: # These are ours, contain a proper message and are "expected"
except FDroidException, e:
if verbose: if verbose:
raise raise
else: else:
print str(e) logging.critical(str(e))
sys.exit(1) sys.exit(1)
# These should only be unexpected crashes due to bugs in the code
# str(e) often doesn't contain a reason, so just show the backtrace
except Exception, e:
logging.critical("Unknown exception found!")
raise
sys.exit(0) sys.exit(0)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -971,7 +971,7 @@ def parse_androidmanifests(paths, ignoreversions=None):
return (max_version, max_vercode, max_package) return (max_version, max_vercode, max_package)
class _FDroidException(Exception): class FDroidException(Exception):
def __init__(self, value, detail=None): def __init__(self, value, detail=None):
self.value = value self.value = value
self.detail = detail self.detail = detail
@ -993,11 +993,11 @@ class _FDroidException(Exception):
return ret return ret
class VCSException(_FDroidException): class VCSException(FDroidException):
pass pass
class BuildException(_FDroidException): class BuildException(FDroidException):
pass pass