Bug 1258497: wrap mach Commands in try/except; r=gps

MozReview-Commit-ID: FTPDTjw4gR

--HG--
extra : rebase_source : a922f03418d9c03f4018940554a23ed341a4e807
extra : histedit_source : 439fda8e499696cca39dff7e1b436f74541d17bb
This commit is contained in:
Dustin J. Mitchell 2016-05-16 17:44:24 +00:00
parent b79ac66e13
commit 05ef600e1c
2 changed files with 22 additions and 16 deletions

View File

@ -7,7 +7,7 @@
from __future__ import absolute_import, print_function, unicode_literals
import sys
import textwrap
import traceback
from mach.decorators import (
CommandArgument,
@ -136,25 +136,32 @@ class MachCommands(MachCommandBase):
the parameters file generated by a decision task. """
import taskgraph.decision
return taskgraph.decision.taskgraph_decision(self.log, options)
try:
return taskgraph.decision.taskgraph_decision(self.log, options)
except Exception as e:
traceback.print_exc()
sys.exit(1)
def show_taskgraph(self, graph_attr, options):
import taskgraph.parameters
import taskgraph.target_tasks
import taskgraph.generator
parameters = taskgraph.parameters.load_parameters_file(options)
try:
parameters = taskgraph.parameters.load_parameters_file(options)
target_tasks_method = parameters.get('target_tasks_method', 'all_tasks')
target_tasks_method = taskgraph.target_tasks.get_method(target_tasks_method)
tgg = taskgraph.generator.TaskGraphGenerator(
root_dir=options['root'],
log=self.log,
parameters=parameters,
target_tasks_method=target_tasks_method)
target_tasks_method = parameters.get('target_tasks_method', 'all_tasks')
target_tasks_method = taskgraph.target_tasks.get_method(target_tasks_method)
tgg = taskgraph.generator.TaskGraphGenerator(
root_dir=options['root'],
log=self.log,
parameters=parameters,
target_tasks_method=target_tasks_method)
tg = getattr(tgg, graph_attr)
for label in tg.graph.visit_postorder():
print(tg.tasks[label])
tg = getattr(tgg, graph_attr)
for label in tg.graph.visit_postorder():
print(tg.tasks[label])
except Exception as e:
traceback.print_exc()
sys.exit(1)

View File

@ -33,8 +33,7 @@ def load_parameters_file(options):
elif filename.endswith('.json'):
return Parameters(**json.load(f))
else:
print("Parameters file `{}` is not JSON or YAML".format(filename))
sys.exit(1)
raise TypeError("Parameters file `{}` is not JSON or YAML".format(filename))
def get_decision_parameters(options):
"""