Use OptionError exceptions

This commit is contained in:
Daniel Martí 2013-12-22 21:39:39 +01:00
parent 0d766cef1c
commit 588277479b
2 changed files with 7 additions and 11 deletions

View file

@ -28,7 +28,7 @@ import traceback
import time import time
import json import json
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
from optparse import OptionParser from optparse import OptionParser, OptionError
import common, metadata import common, metadata
from common import BuildException, VCSException, FDroidPopen from common import BuildException, VCSException, FDroidPopen
@ -820,8 +820,7 @@ def parse_commandline():
options.stop = True options.stop = True
if options.force and not options.test: if options.force and not options.test:
print "Force is only allowed in test mode" raise OptionError("Force is only allowed in test mode", "force")
sys.exit(1)
return options, args return options, args
@ -834,16 +833,14 @@ def main():
options, args = parse_commandline() options, args = parse_commandline()
if not args and not options.all: if not args and not options.all:
print "If you really want to build all the apps, use --all" raise OptionError("If you really want to build all the apps, use --all", "all")
sys.exit(1)
config = common.read_config(options) config = common.read_config(options)
if config['build_server_always']: if config['build_server_always']:
options.server = True options.server = True
if options.resetserver and not options.server: if options.resetserver and not options.server:
print "Using --resetserver without --server makes no sense" raise OptionError("Using --resetserver without --server makes no sense", "resetserver")
sys.exit(1)
log_dir = 'logs' log_dir = 'logs'
if not os.path.isdir(log_dir): if not os.path.isdir(log_dir):

View file

@ -21,7 +21,7 @@
import sys import sys
import os import os
import glob import glob
from optparse import OptionParser from optparse import OptionParser, OptionError
import common import common
from common import FDroidPopen from common import FDroidPopen
@ -49,15 +49,14 @@ def main():
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if not args and not options.all: if not args and not options.all:
print "If you really want to install all the signed apps, use --all" raise OptionError("If you really want to install all the signed apps, use --all", "all")
sys.exit(1)
config = common.read_config(options) config = common.read_config(options)
output_dir = 'repo' output_dir = 'repo'
if not os.path.isdir(output_dir): if not os.path.isdir(output_dir):
print "No signed output directory - nothing to do" print "No signed output directory - nothing to do"
sys.exit(1) sys.exit(0)
if args: if args: