def processEnded(self, reason):
        """
        Called when the process has ended.

        @param reason: a Failure giving the reason for the process' end.
        """
        if reason.value.exitCode != 0:
            self._getDeferred().errback(
                ConchError("exit code was not 0: {}".format(
                                 reason.value.exitCode)))
        else:
            buf = self.buf.replace(b'\r\n', b'\n')
            self._getDeferred().callback(buf)

        Called when the process has ended.

        @param reason: a Failure giving the reason for the process' end.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/conch/test/test_conch.py