Skip to content

Commit

Permalink
include actions in bw verify
Browse files Browse the repository at this point in the history
  • Loading branch information
trehn committed May 28, 2018
1 parent 9eeb1af commit 6fe21c0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
6 changes: 6 additions & 0 deletions bundlewrap/items/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,9 @@ def validate_attributes(cls, bundle, item_id, attributes):
raise BundleError(_(
"invalid interactive setting for action '{item}' in bundle '{bundle}'"
).format(item=item_id, bundle=bundle.name))

def verify(self):
if self.unless and self.cached_unless_result:
return self.cached_unless_result, None
else:
raise NotImplementedError
43 changes: 24 additions & 19 deletions bundlewrap/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,10 +805,7 @@ def method(self):
def verify_items(node, show_all=False, workers=1):
items = []
for item in node.items:
if (
not item.ITEM_TYPE_NAME == 'action' and
not item.triggered
):
if not item.triggered:
items.append(item)
elif not isinstance(item, DummyItem):
io.progress_advance()
Expand Down Expand Up @@ -841,22 +838,30 @@ def next_task():
}

def handle_exception(task_id, exception, traceback):
# Unlike with `bw apply`, it is OK for `bw verify` to encounter
# exceptions when getting an item's status. `bw verify` doesn't
# care about dependencies and therefore cannot know that looking
# up a database user requires the database to be installed in
# the first place.
io.progress_advance()
io.debug("exception while verifying {}:".format(task_id))
io.debug(traceback)
io.debug(repr(exception))
node_name, bundle_name, item_id = task_id.split(":", 2)
io.stdout(_("{x} {node} {bundle} {item} (unable to get status, check --debug for details)").format(
bundle=bold(bundle_name),
item=item_id,
node=bold(node_name),
x=cyan("?"),
))
io.progress_advance()
if isinstance(exception, NotImplementedError):
io.stdout(_("{x} {node} {bundle} {item} (does not support verify)").format(
bundle=bold(bundle_name),
item=item_id,
node=bold(node_name),
x=cyan("?"),
))
else:
# Unlike with `bw apply`, it is OK for `bw verify` to encounter
# exceptions when getting an item's status. `bw verify` doesn't
# care about dependencies and therefore cannot know that looking
# up a database user requires the database to be installed in
# the first place.
io.debug("exception while verifying {}:".format(task_id))
io.debug(traceback)
io.debug(repr(exception))
io.stdout(_("{x} {node} {bundle} {item} (unable to get status, check --debug for details)").format(
bundle=bold(bundle_name),
item=item_id,
node=bold(node_name),
x=cyan("?"),
))
return None # count this result as "unknown"

def handle_result(task_id, return_value, duration):
Expand Down

0 comments on commit 6fe21c0

Please sign in to comment.