Commit 309d4db7 authored by Vincent Pelletier's avatar Vincent Pelletier

Reduce try..except scope.

parent 6e2f0a69
...@@ -859,7 +859,6 @@ class Parser(OptionParser): ...@@ -859,7 +859,6 @@ class Parser(OptionParser):
return options, args[0] return options, args[0]
def run(config): def run(config):
try:
# Define the computer # Define the computer
if config.input_definition_file: if config.input_definition_file:
filepath = os.path.abspath(config.input_definition_file) filepath = os.path.abspath(config.input_definition_file)
...@@ -980,9 +979,6 @@ def run(config): ...@@ -980,9 +979,6 @@ def run(config):
computer.dump(config.computer_xml) computer.dump(config.computer_xml)
config.logger.info('Posting information to %r' % config.master_url) config.logger.info('Posting information to %r' % config.master_url)
computer.send(config) computer.send(config)
except:
config.logger.exception('Uncaught exception:')
raise
class Config: class Config:
def checkRequiredBinary(self, binary_list): def checkRequiredBinary(self, binary_list):
...@@ -1104,11 +1100,15 @@ def main(*args): ...@@ -1104,11 +1100,15 @@ def main(*args):
real_callAndRead = callAndRead real_callAndRead = callAndRead
usage = "usage: %s [options] CONFIGURATION_FILE" % sys.argv[0] usage = "usage: %s [options] CONFIGURATION_FILE" % sys.argv[0]
try:
# Parse arguments # Parse arguments
options, configuration_file_path = Parser(usage=usage).check_args(args) options, configuration_file_path = Parser(usage=usage).check_args(args)
config = Config() config = Config()
try:
config.setConfig(options, configuration_file_path) config.setConfig(options, configuration_file_path)
except UsageError, err:
print >>sys.stderr, err.msg
print >>sys.stderr, "For help use --help"
sys.exit(1)
os = OS(config) os = OS(config)
if config.dry_run: if config.dry_run:
def dry_callAndRead(argument_list, raise_on_error=True): def dry_callAndRead(argument_list, raise_on_error=True):
...@@ -1136,7 +1136,8 @@ def main(*args): ...@@ -1136,7 +1136,8 @@ def main(*args):
config.logger.debug(' '.join(argument_list)) config.logger.debug(' '.join(argument_list))
return dry_callAndRead(argument_list, raise_on_error) return dry_callAndRead(argument_list, raise_on_error)
callAndRead = logging_callAndRead callAndRead = logging_callAndRead
try:
run(config) run(config)
except UsageError, err: except:
print >>sys.stderr, err.msg config.logger.exception('Uncaught exception:')
print >>sys.stderr, "For help use --help" raise
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment