'Execute a command with \'command\', check the result code and throw an appropriate
FatalError if it fails.
Returns the "result" of a successful command.'

def check_command(self, op_description, op=None, data='', chk=0):

    (val, data) = self.command(op, data, chk)
    if (len(data) < self.STATUS_BYTES_LENGTH):
        raise FatalError(('Failed    to    %s.    Only    got    %d    byte    status    response.' % (op_description, len(data))))
    status_bytes = data[(- self.STATUS_BYTES_LENGTH):]
    if (byte(status_bytes, 0) != 0):
        raise FatalError.WithResult(('Failed    to    %s' % op_description), status_bytes)
    if (len(data) > self.STATUS_BYTES_LENGTH):
        return data[:(- self.STATUS_BYTES_LENGTH)]
    else:
        return val
