MCPcopy Index your code
hub / github.com/pyinvoke/invoke / UnexpectedExit

Class UnexpectedExit

invoke/exceptions.py:106–140  ·  view source on GitHub ↗

A shell command ran to completion but exited with an unexpected exit code. Its string representation displays the following: - Command executed; - Exit code; - The last 10 lines of stdout, if it was hidden; - The last 10 lines of stderr, if it was hidden and non-empty (e.g

Source from the content-addressed store, hash-verified

104
105
106class UnexpectedExit(Failure):
107 """
108 A shell command ran to completion but exited with an unexpected exit code.
109
110 Its string representation displays the following:
111
112 - Command executed;
113 - Exit code;
114 - The last 10 lines of stdout, if it was hidden;
115 - The last 10 lines of stderr, if it was hidden and non-empty (e.g.
116 pty=False; when pty=True, stderr never happens.)
117
118 .. versionadded:: 1.0
119 """
120
121 def __str__(self) -> str:
122 stdout, stderr = self.streams_for_display()
123 command = self.result.command
124 exited = self.result.exited
125 template = """Encountered a bad command exit code!
126
127Command: {!r}
128
129Exit code: {}
130
131Stdout:{}
132
133Stderr:{}
134
135"""
136 return template.format(command, exited, stdout, stderr)
137
138 def _repr(self, **kwargs: Any) -> str:
139 kwargs.setdefault("exited", self.result.exited)
140 return super()._repr(**kwargs)
141
142
143class CommandTimedOut(Failure):

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…