PERFORCE change 122199 for review
Andrew Turner
andrew at FreeBSD.org
Sat Jun 23 10:54:30 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=122199
Change 122199 by andrew at 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)
More information about the p4-projects
mailing list