def cmd(self, operation): """ put a mapi command on the line""" logger.debug("II: executing command %s" % operation) if self.state != STATE_READY: raise ProgrammingError self.__putblock(operation) response = self.__getblock() if not len(response): return "" elif response.startswith(MSG_OK): return response[3:].strip() or "" if response == MSG_MORE: # tell server it isn't going to get more return self.cmd("") if response[0] in [MSG_Q, MSG_HEADER, MSG_TUPLE]: return response elif response[0] == MSG_ERROR: raise OperationalError(response[1:]) else: raise ProgrammingError("unknown state: %s" % response)
def isempty(result): """ raises an exception if the result is not empty""" if result != "": raise OperationalError(result) else: return True