def _registerSystem(self, espmlFile): """ Execute this function to validate the espml that comes in """ # ** We need a way to validate the XML by comparing it to the schema. espmlDocObject = espml.parse(espmlFile) for field in espmlDocObject.getField(): for fieldFunc in field.getFunction(): tempFunctionName = 'field_' + fieldFunc.name if hasattr(self, tempFunctionName): print tempFunctionName, "exists" else: raise FunctionError(tempFunctionName) for platform in field.getPlatform(): for platformFunc in platform.getFunction(): tempFunctionName = 'platform_' + platformFunc.name if hasattr(self, tempFunctionName): print tempFunctionName, "exists" else: raise FunctionError(tempFunctionName) for sensor in platform.getSensor(): for sensorFunc in sensor.getFunction(): tempFunctionName = 'sensor_' + sensorFunc.name if hasattr(self, tempFunctionName): print tempFunctionName, "exists" else: raise FunctionError(tempFunctionName) # need to get ids and also function names # Register the espml with the registry. # print hasattr(self, "bar") # print hasattr(self, "_registerSystem") espmlDocObject = espml.parse(espmlFile) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) print "Registering XML:" print espmlDocXml.getvalue() #self.execute(espmlDocXml.getvalue()) returnValue = self._registry.register(espmlDocXml.getvalue()) print returnValue
def __init__(self): global _requests self.camip = "sonycam.msgroup.ucla.edu" self.ourip = socket.gethostbyaddr(socket.gethostname())[-1][0] self.port = 9218 self.camtool = "./camctrl" self.pan = 0 self.tilt = 0 self.zoom = 0 self.setCam() print "Start parsing xml file" espmlFile = 'sonyCamSystem.xml' espmlDocObject = espml.parse(espmlFile) systemElement = espmlDocObject.getSystem() systemElement.setId('http://' + str(self.ourip) + ':' + self.port) espmlDocObject.export(file(espmlFile, 'w'), 0) System.__init__(self, self.port, "http://128.97.93.5:1718/", "sonyCamSystem.xml") print "Registered system" #the next call is blocking! print "starting..." self.start() raw_input("Press a key when done")
def __init__(self): global _requests self.camip = "sonycam.msgroup.ucla.edu" self.ourip = socket.gethostbyaddr(socket.gethostname())[-1][0] self.port = 9218 self.camtool = "./camctrl" self.pan=0 self.tilt=0 self.zoom=0 self.setCam() print "Start parsing xml file" espmlFile = 'sonyCamSystem.xml' espmlDocObject = espml.parse(espmlFile) systemElement = espmlDocObject.getSystem() systemElement.setId('http://'+str(self.ourip)+':'+self.port) espmlDocObject.export(file(espmlFile, 'w'), 0) System.__init__(self, self.port, "http://128.97.93.5:1718/", "sonyCamSystem.xml") print "Registered system" #the next call is blocking! print "starting..." self.start() raw_input("Press a key when done")
def __init__(self): self.system = SOAPpy.SOAPProxy("http://localhost:8081") espmlFile = "sos_function.xml" espmlDocObject = espml.parse(espmlFile) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) r = self.system.execute(espmlDocXml.getvalue()) print r
def __init__(self): self.system = SOAPpy.SOAPProxy("http://localhost:7081") espmlFile = "soundscape_function.xml" espmlDocObject = espml.parse(espmlFile) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) r = self.system.execute(espmlDocXml.getvalue()) espmlResponse = espml.parseString(r) field = espmlResponse.getField()[0] functions = field.getFunction() sessionId = None for f in functions: if f.getName() == "getSessionId": sessionId = f.getOutput()[0].getUri() if sessionId == None: print "No session ID received." sys.exit(1) #now, submit a timestamp and audio file at the same time espmlDocObject = espml.parse("soundscape_function2.xml") field = espmlDocObject.getField()[0] functions = field.getFunction() for f in functions: if f.getName() == "uploadLocation": f.addParameter(espml.parameter(name="sessionId", value=sessionId)) f.addParameter(espml.parameter(name="timestamp", value=timestamp)) f.addParameter(espml.parameter(name="location", value=location)) if f.getName() == "uploadMedia": f.addParameter(espml.parameter(name="sessionId", value=sessionId)) f.addParameter(espml.parameter(name="timestamp", value=timestamp)) f.addParameter(espml.parameter(name="mediaFile", value=base64.b64encode(mediaFileString))) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) #print espmlDocXml.getvalue() r = self.system.execute(espmlDocXml.getvalue())
def _unRegisterSystem(self, espmlFile): """ Execute this function to validate the espml that comes in """ # ** We need a way to validate the XML by comparing it to the schema. # Register the espml with the registry. espmlDocObject = espml.parse(espmlFile) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) self._registry.unRegister(espmlDocXml)
def _registerSystem(self, espmlFile): """ Execute this function to validate the espml that comes in """ # Register the espml with the registry. # print hasattr(self, "_registerSystem") espmlDocObject = espml.parse(espmlFile) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) print "Registering XML:" print espmlDocXml.getvalue() returnValue = self._registry.register(espmlDocXml.getvalue()) print returnValue
def __init__(self): self.system = SOAPpy.SOAPProxy("http://*****:*****@ee.ucla.edu")) f.addParameter(espml.parameter(name="password", value="intel")) f.addParameter(espml.parameter(name="overwriteData", value="1")) f.addParameter(espml.parameter(name="dataType", value="xml")) f.addParameter(espml.parameter(name="dataFile", value=dataFileValue)) if f.getName() == "performQuery": f.addParameter(espml.parameter(name="dataType", value="xml")) f.addParameter(espml.parameter(name="queryString", value="SELECT+*+FROM+p_12_data")) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) print espmlDocXml.getvalue() r = self.system.execute(espmlDocXml.getvalue())
def processRequest(self, dict, baseFunctionCallFile): print "Content-Type: text/html\n" print "<html><head><title>functionCall</title></head>" print "<body>" print "<pre>" #print self.dict tempKey = 0 espmlDocObject = espml.parse(baseFunctionCallFile) if(dict.has_key('system')): if(dict.has_key('system')): espmlDocObject.setId(str(dict['system'])) for field in espmlDocObject.getField(): if(dict.has_key('field')): field.setId(int(dict['field'])) if(dict.has_key('platform')): pass else: field.addFunction(espml.function(dict['name'], 'General Function Description')) for key in dict.keys(): if((key != 'system') and (key != 'name') and (key != 'platform') and (key != 'sensor') and (key != 'field')): for function in field.getFunction(): param = espml.parameter(str(key)) param.setValue(str(dict[key])) function.addParameter(param) for platform in field.getPlatform(): if(dict.has_key('platform')): platform.setId(int(dict['platform'])) if(dict.has_key('sensor')): pass else: platform.addFunction(espml.function(dict['name'], 'General Function Description')) for key in dict.keys(): if((key != 'system') and (key != 'name') and (key != 'platform') and (key != 'sensor') and (key != 'field')): for function in platform.getFunction(): param = espml.parameter(str(key)) param.setValue(str(dict[key])) function.addParameter(param) for sensor in platform.getSensor(): if(dict.has_key('sensor')): sensor.setId(int(dict['sensor'])) sensor.addFunction(espml.function(dict['name'], 'General Function Description')) for key in dict.keys(): if((key != 'system') and (key != 'name') and (key != 'platform') and (key != 'sensor') and (key != 'field')): for function in sensor.getFunction(): param = espml.parameter(str(key)) param.setValue(str(dict[key])) function.addParameter(param) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) #print espmlDocXml.getvalue() #print espmlDocObject.getId() system = SOAPpy.SOAPProxy(espmlDocObject.getId()) functionOutputXML = system.execute(espmlDocXml.getvalue()) espmlDocObject = espml.parseString(functionOutputXML) for field in espmlDocObject.getField(): for function in field.getFunction(): print 'Function:', function.getName() for output in function.getOutput(): print 'Type:', output.getType() if((str(output.getType()) == "OK") or (str(output.getType()) == "ERROR")): print 'Response: ' + str(output.getUri()) else: print 'URI:' + '<a href="' + str(output.getUri()) + '">' + str(output.getUri()) + '</a>' for platform in field.getPlatform(): for function in platform.getFunction(): print 'Function:', function.getName() for output in function.getOutput(): print 'Type:', output.getType() if((str(output.getType()) == "OK") or (str(output.getType()) == "ERROR")): print 'Response: ' + str(output.getUri()) else: print 'URI:' + '<a href="' + str(output.getUri()) + '">' + str(output.getUri()) + '</a>' for sensor in platform.getSensor(): for function in sensor.getFunction(): print 'Function:', function.getName() for output in function.getOutput(): print 'Type:', output.getType() if((str(output.getType()) == "OK") or (str(output.getType()) == "ERROR")): print 'Response: ' + str(output.getUri()) else: print 'URI:' + '<a href="' + str(output.getUri()) + '">' + str(output.getUri()) + '</a>' print "</pre>" print "</body>" print "</html>"
def processRequest(self, dict, baseFunctionCallFile): print "Content-Type: text/html\n" print "<html><head><title>functionCall</title></head>" print "<body>" print "<pre>" #print self.dict tempKey = 0 espmlDocObject = espml.parse(baseFunctionCallFile) if (dict.has_key('system')): if (dict.has_key('system')): espmlDocObject.setId(str(dict['system'])) for field in espmlDocObject.getField(): if (dict.has_key('field')): field.setId(int(dict['field'])) if (dict.has_key('platform')): pass else: field.addFunction( espml.function(dict['name'], 'General Function Description')) for key in dict.keys(): if ((key != 'system') and (key != 'name') and (key != 'platform') and (key != 'sensor') and (key != 'field')): for function in field.getFunction(): param = espml.parameter(str(key)) param.setValue(str(dict[key])) function.addParameter(param) for platform in field.getPlatform(): if (dict.has_key('platform')): platform.setId(int(dict['platform'])) if (dict.has_key('sensor')): pass else: platform.addFunction( espml.function(dict['name'], 'General Function Description')) for key in dict.keys(): if ((key != 'system') and (key != 'name') and (key != 'platform') and (key != 'sensor') and (key != 'field')): for function in platform.getFunction(): param = espml.parameter(str(key)) param.setValue(str(dict[key])) function.addParameter(param) for sensor in platform.getSensor(): if (dict.has_key('sensor')): sensor.setId(int(dict['sensor'])) sensor.addFunction( espml.function(dict['name'], 'General Function Description')) for key in dict.keys(): if ((key != 'system') and (key != 'name') and (key != 'platform') and (key != 'sensor') and (key != 'field')): for function in sensor.getFunction(): param = espml.parameter(str(key)) param.setValue(str(dict[key])) function.addParameter(param) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) #print espmlDocXml.getvalue() #print espmlDocObject.getId() system = SOAPpy.SOAPProxy(espmlDocObject.getId()) functionOutputXML = system.execute(espmlDocXml.getvalue()) espmlDocObject = espml.parseString(functionOutputXML) for field in espmlDocObject.getField(): for function in field.getFunction(): print 'Function:', function.getName() for output in function.getOutput(): print 'Type:', output.getType() if ((str(output.getType()) == "OK") or (str(output.getType()) == "ERROR")): print 'Response: ' + str(output.getUri()) else: print 'URI:' + '<a href="' + str( output.getUri()) + '">' + str( output.getUri()) + '</a>' for platform in field.getPlatform(): for function in platform.getFunction(): print 'Function:', function.getName() for output in function.getOutput(): print 'Type:', output.getType() if ((str(output.getType()) == "OK") or (str(output.getType()) == "ERROR")): print 'Response: ' + str(output.getUri()) else: print 'URI:' + '<a href="' + str( output.getUri()) + '">' + str( output.getUri()) + '</a>' for sensor in platform.getSensor(): for function in sensor.getFunction(): print 'Function:', function.getName() for output in function.getOutput(): print 'Type:', output.getType() if ((str(output.getType()) == "OK") or (str(output.getType()) == "ERROR")): print 'Response: ' + str(output.getUri()) else: print 'URI:' + '<a href="' + str( output.getUri()) + '">' + str( output.getUri()) + '</a>' print "</pre>" print "</body>" print "</html>"
def __init__(self): self.system = SOAPpy.SOAPProxy("http://*****:*****@ee.ucla.edu")) f.addParameter(espml.parameter(name="password", value="intel")) f.addParameter(espml.parameter(name="overwriteData", value="1")) f.addParameter(espml.parameter(name="dataType", value="xml")) f.addParameter( espml.parameter(name="dataFile", value=dataFileValue)) if f.getName() == "performQuery": f.addParameter(espml.parameter(name="dataType", value="xml")) f.addParameter( espml.parameter(name="queryString", value="SELECT+*+FROM+p_12_data")) espmlDocXml = StringIO.StringIO() espmlDocObject.export(espmlDocXml, 0) print espmlDocXml.getvalue() r = self.system.execute(espmlDocXml.getvalue())