Fix: only attempt to fetch OP meta if we have a pseudo host.
@@ -17,13 +17,6 @@ from pyinfra.hook import Error as HookError
class CliError(PyinfraError, click.ClickException):
def show(self):
- # Get any operation meta + name
- op_name = None
- current_op_hash = pseudo_state.current_op_hash
- current_op_meta = pseudo_state.op_meta.get(current_op_hash)
- if current_op_meta:
- op_name = ', '.join(current_op_meta['names'])
-
name = 'unknown error'
if isinstance(self, HookError):
@@ -36,6 +29,13 @@ class CliError(PyinfraError, click.ClickException):
name = 'local IO error'
if pseudo_host.isset():
+ # Get any operation meta + name
+ op_name = None
+ current_op_hash = pseudo_state.current_op_hash
+ current_op_meta = pseudo_state.op_meta.get(current_op_hash)
+ if current_op_meta:
+ op_name = ', '.join(current_op_meta['names'])
+
sys.stderr.write('--> {0}{1}{2}: '.format(
pseudo_host.print_prefix,
click.style(name, 'red', bold=True),
