Date: Sat, 23 Jun 2007 10:54:29 GMT From: Andrew Turner <andrew@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 122199 for review Message-ID: <200706231054.l5NAsT1S019708@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122199 Change 122199 by andrew@andrew_hermies on 2007/06/23 10:54:13 Read in the facund data types from the network Fix a typo send -> sent Affected files ... .. //depot/projects/soc2007/andrew-update/frontend/facund/network/__init__.py#6 edit Differences ... ==== //depot/projects/soc2007/andrew-update/frontend/facund/network/__init__.py#6 (text+ko) ==== @@ -24,6 +24,7 @@ # SUCH DAMAGE. # +import facund import socket import threading import xml.sax.handler @@ -32,6 +33,9 @@ '''A class that works as a client with the Facund XML IPC''' def __init__(self, server): self.isReady = False + + self.__data = None + self.bufSize = 1024 self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.socket.connect(server) @@ -71,16 +75,49 @@ def startElement(self, name, attributes): print "> " + name + " " + str(attributes.items()) - if self.isReady and name == "pong": - self.socket.send("<call name=\"ping\" id=\"1\"/>") + + if name == "data": + data_type = None + data = None + for attr in attributes.items(): + if attr[0] == "type": + # TODO: If data_type is not None then raise exception + data_type = attr[1] + + if data_type == "bool": + data = facund.Bool() + elif data_type == "int": + data = facund.Int() + elif data_type == "unsigned int": + data = facund.UInt() + elif data_type == "string": + data = facund.String() + elif data_type == "array": + data = facund.Array() + + # TODO: Check if data == None + data.setParent(self.__data) + self.__data = data - if name == "facund-server": + elif name == "facund-server": self.__connected_lock.acquire() def endElement(self, name): print "< " + name - # The server send a close message - if name == "facund-server": + + if name == "data": + data = self.__data.getParent() + if data is not None: + self.__data = data + + elif name == "response": + print str(self.__data) + + elif name == "facund-server": + # The server sent a close message self.__connected_lock.release() self.canClose = True + def characters(self, text): + print "==> " + text + self.__data.setData(text)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706231054.l5NAsT1S019708>