pymensago/serverconn.py
def read_response(self, schema: dict=None) -> RetVal:
		'''Reads a server response and returns a separated code and string'''
		
		if not self.socket:
			return None
		
		if schema is None:
			schema = server_response

		# We don't actually handle the possible exceptions because we *want* to have them crash --
		# the test will fail and give us the cause of the exception. If we have a successful test, 
		# exceptions weren't thrown
		try:
			rawdata = self.socket.recv(READ_BUFFER_SIZE)
			rawstring = rawdata.decode()
			rawresponse = json.loads(rawstring)
			if schema:
				jsonschema.validate(rawresponse, schema)
		except Exception as e:
			return RetVal().wrap_exception(e)

		response = RetVal().set_values({
			'Code': rawresponse['Code'],
			'Status': rawresponse['Status'],
			'Info': rawresponse['Info'],
			'Data': rawresponse['Data']
		})
		return response
Reads a server response and returns a separated code and string
Reads a server response and returns a separated code and string
Reads a server response and returns a separated code and string
def read_response(self, schema: dict=None) -> RetVal:
		if not self.socket:
			return None
		if schema is None:
			schema = server_response
		try:
			rawdata = self.socket.recv(READ_BUFFER_SIZE)
			rawstring = rawdata.decode()
			rawresponse = json.loads(rawstring)
			if schema:
				jsonschema.validate(rawresponse, schema)
		except Exception as e:
			return RetVal().wrap_exception(e)
		response = RetVal().set_values({
			'Code': rawresponse['Code'],
			'Status': rawresponse['Status'],
			'Info': rawresponse['Info'],
			'Data': rawresponse['Data']
		})
		return response
def read_response ( self , schema : dict = None ) -> RetVal : if not self . socket : return None if schema is None : schema = server_response try : rawdata = self . socket . recv ( READ_BUFFER_SIZE ) rawstring = rawdata . decode ( ) rawresponse = json . loads ( rawstring ) if schema : jsonschema . validate ( rawresponse , schema ) except Exception as e : return RetVal ( ) . wrap_exception ( e ) response = RetVal ( ) . set_values ( { 'Code' : rawresponse [ 'Code' ] , 'Status' : rawresponse [ 'Status' ] , 'Info' : rawresponse [ 'Info' ] , 'Data' : rawresponse [ 'Data' ] } ) return response
Reads a server response and returns a separated code and string
Reads a server response and returns a separated code and string
'''Reads a server response and returns a separated code and string''' # We don't actually handle the possible exceptions because we *want* to have them crash -- # the test will fail and give us the cause of the exception. If we have a successful test,  # exceptions weren't thrown
self
schema
dict