Example #1
0
 async def show_strat(self):
     await self.send_command('SHOW STRAT\r\n')
     code, response, body = await self.recv_response()
     if code == ResponseCodes.STRATEGIES_AVAILABLE:
         return body
     elif code == ResponseCodes.NO_STRATEGIES_AVAILABLE:
         return []
     raise DictError(code, response)
Example #2
0
 async def quit(self):
     await self.send_command('QUIT\r\n')
     code, response, _ = await self.recv_response()
     if code == ResponseCodes.CONECTION_CLOSING:
         self.writer.close()
         self.connected = False
         return
     raise DictError(code, response)
Example #3
0
 async def show_info(self, database):
     await self.send_command('SHOW INFO {}\r\n'.format(database))
     code, response, body = await self.recv_response()
     if code == ResponseCodes.DATABASE_INFORMATION:
         return body
     elif code == ResponseCodes.INVALID_DATABASE:
         raise InvalidDatabase(code, response)
     raise DictError(code, response)
Example #4
0
 async def show_db(self):
     await self.send_command('SHOW DB\r\n')
     code, response, body = await self.recv_response()
     if code == ResponseCodes.DATABASES_PRESENT:
         return body
     elif code == ResponseCodes.NO_DATABASES_PRESENT:
         return []
     raise DictError(code, response)
Example #5
0
 async def define(self, database, word):
     await self.send_command('DEFINE {} "{}"\r\n'.format(database, word))
     code, response, body = await self.recv_response()
     if code == ResponseCodes.NO_MATCH:
         return []
     elif code == ResponseCodes.DEFINITIONS_RETRIEVED:
         return body
     elif code == ResponseCodes.INVALID_DATABASE:
         raise InvalidDatabase(code, response)
     raise DictError(code, response)
Example #6
0
 async def match(self, database, strategy, word):
     await self.send_command('MATCH {} {} "{}"\r\n'.format(database, strategy, word))
     code, response, body = await self.recv_response()
     if code == ResponseCodes.NO_MATCH:
         return []
     elif code == ResponseCodes.MATCHES_FOUND:
         return body
     elif code == ResponseCodes.INVALID_DATABASE:
         raise InvalidDatabase(code, response)
     elif code == ResponseCodes.INVALID_STRATEGY:
         raise InvalidStrategy(code, response)
     raise DictError(code, response)
Example #7
0
 async def client(self, text):
     await self.send_command('CLIENT {}\r\n'.format(text))
     code, response, _ = await self.recv_response()
     if code == ResponseCodes.OK:
         return
     raise DictError(code, response)
Example #8
0
 async def option_mime(self):
     await self.send_command('OPTION MIME\r\n')
     code, response, _ = await self.recv_response()
     if code == ResponseCodes.OK:
         return response
     raise DictError(code, response)
Example #9
0
 async def help(self):
     await self.send_command('HELP\r\n')
     code, response, body = await self.recv_response()
     if code == ResponseCodes.HELP_TEXT:
         return body
     raise DictError(code, response)
Example #10
0
 async def status(self):
     await self.send_command('STATUS\r\n')
     code, response, _ = await self.recv_response()
     if code == ResponseCodes.STATUS_INFO:
         return response
     raise DictError(code, response)
Example #11
0
 async def show_server(self):
     await self.send_command('SHOW SERVER\r\n')
     code, response, body = await self.recv_response()
     if code == ResponseCodes.SERVER_INFORMATION:
         return body
     raise DictError(code, response)