chiark / gitweb /
Use OptionError exceptions
authorDaniel Martí <mvdan@mvdan.cc>
Sun, 22 Dec 2013 20:39:39 +0000 (21:39 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Sun, 22 Dec 2013 20:39:39 +0000 (21:39 +0100)
fdroidserver/build.py
fdroidserver/install.py

index 184584e7f62c6d77276f20cd63a6899c7192beaf..0bc49874d9b2305c2b2794e1298dcf4701018829 100644 (file)
@@ -28,7 +28,7 @@ import traceback
 import time
 import json
 from ConfigParser import ConfigParser
-from optparse import OptionParser
+from optparse import OptionParser, OptionError
 
 import common, metadata
 from common import BuildException, VCSException, FDroidPopen
@@ -820,8 +820,7 @@ def parse_commandline():
         options.stop = True
 
     if options.force and not options.test:
-        print "Force is only allowed in test mode"
-        sys.exit(1)
+        raise OptionError("Force is only allowed in test mode", "force")
 
     return options, args
 
@@ -834,16 +833,14 @@ def main():
 
     options, args = parse_commandline()
     if not args and not options.all:
-        print "If you really want to build all the apps, use --all"
-        sys.exit(1)
+        raise OptionError("If you really want to build all the apps, use --all", "all")
 
     config = common.read_config(options)
 
     if config['build_server_always']:
         options.server = True
     if options.resetserver and not options.server:
-        print "Using --resetserver without --server makes no sense"
-        sys.exit(1)
+        raise OptionError("Using --resetserver without --server makes no sense", "resetserver")
 
     log_dir = 'logs'
     if not os.path.isdir(log_dir):
index a133ede59576c96c2ec446096c9b9313c22aac8b..b61cfcb447de49bf0331aa562c5a69f275e0fbfe 100644 (file)
@@ -21,7 +21,7 @@
 import sys
 import os
 import glob
-from optparse import OptionParser
+from optparse import OptionParser, OptionError
 
 import common
 from common import FDroidPopen
@@ -49,15 +49,14 @@ def main():
     (options, args) = parser.parse_args()
 
     if not args and not options.all:
-        print "If you really want to install all the signed apps, use --all"
-        sys.exit(1)
+        raise OptionError("If you really want to install all the signed apps, use --all", "all")
 
     config = common.read_config(options)
 
     output_dir = 'repo'
     if not os.path.isdir(output_dir):
         print "No signed output directory - nothing to do"
-        sys.exit(1)
+        sys.exit(0)
 
     if args: