Skip to content

Commit

Permalink
catch inspection errors and print them
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikovic authored and vinzenz committed Jun 7, 2018
1 parent b406c1d commit 0dbec84
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
8 changes: 7 additions & 1 deletion leapp/cli/upgrade/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import uuid

import sys
from leapp.config import get_config
from leapp.exceptions import LeappError
from leapp.logger import configure_logger
from leapp.repository.scan import find_and_scan_repositories
from leapp.utils.audit import Execution, get_connection, get_checkpoints
Expand Down Expand Up @@ -57,7 +59,11 @@ def upgrade(args):
if args.resume:
logger.info("Resuming execution after phase: %s", skip_phases_until)

repositories = load_repositories()
try:
repositories = load_repositories()
except LeappError as exc:
sys.stderr.write(exc.message)
sys.exit(1)
workflow = repositories.lookup_workflow('IPUWorkflow')()
workflow.run(context=context, skip_phases_until=skip_phases_until)
report_errors(workflow.errors)
7 changes: 6 additions & 1 deletion leapp/snactor/commands/discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import sys

from leapp.exceptions import LeappError
from leapp.topics import get_topics
from leapp.models import get_models
from leapp.repository.scan import scan_repo
Expand Down Expand Up @@ -83,7 +84,11 @@ def _get_model_details(model):
def cli(args):
base_dir = find_project_basedir('.')
repository = scan_repo(base_dir)
repository.load()
try:
repository.load()
except LeappError as exc:
sys.stderr.write(exc.message)
sys.exit(1)

actors = [actor for actor in repository.actors]
models = [model for model in get_models() if _is_local(base_dir, model)]
Expand Down
7 changes: 6 additions & 1 deletion leapp/snactor/commands/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import sys

from leapp.exceptions import LeappError
from leapp.utils.clicmd import command, command_opt, command_arg
from leapp.utils.project import requires_project, find_project_basedir
from leapp.logger import configure_logger
Expand Down Expand Up @@ -28,7 +29,11 @@ def cli(args):
log = configure_logger()
basedir = find_project_basedir('.')
repository = scan_repo(basedir)
repository.load()
try:
repository.load()
except LeappError as exc:
sys.stderr.write(exc.message)
sys.exit(1)
actor_logger = log.getChild('actors')
actor = repository.lookup_actor(args.actor_name)
messaging = InProcessMessaging(stored=args.save_output)
Expand Down
8 changes: 7 additions & 1 deletion leapp/snactor/commands/workflow/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import print_function

import leapp.workflows
import sys
from leapp.exceptions import LeappError
from leapp.snactor.commands.workflow import workflow
from leapp.utils.clicmd import command_arg, command_opt
from leapp.logger import configure_logger
Expand Down Expand Up @@ -30,7 +32,11 @@
def cli(params):
configure_logger()
repository = scan_repo(find_project_basedir('.'))
repository.load()
try:
repository.load()
except LeappError as exc:
sys.stderr.write(exc.message)
sys.exit(1)
for wf in leapp.workflows.get_workflows():
if wf.name.lower() == params.name.lower():
instance = wf()
Expand Down

0 comments on commit 0dbec84

Please sign in to comment.