Beispiel #1
0
    def __init__(self):

        system = espml.system()
        system.setId('http://128.97.93.154:9081')

        f = file('geozip.txt')
        oldState = ''
        cnt = 1
        for line in f:
            splitLine = line.split()

            state = splitLine[0][0:2]
            if state not in ('CA', 'MS', 'GA', 'TX', 'CT', 'NV', 'AZ'):
                continue
            try:
                zipCode = int(splitLine[0][2:])
            except (ValueError, IndexError):
                continue
            lattitude = splitLine[-2]
            longitude = splitLine[-1]

            p = espml.point('%s, %s, 0' % (lattitude, longitude))
            l = espml.location(point=[p])
            if not (oldState == state):
                oldState = state
                field = espml.field(id=cnt, description=state)
                field.setLocation(l)
                system.addField(field)
                cnt += 1

            platform = espml.platform(id=zipCode)
            platform.setLocation(l)
            sensor = espml.sensor(id=1,
                                  ttype='weather',
                                  description='Weather for Zip %d' %
                                  (zipCode, ))
            sensor.setLocation(l)
            function = espml.function(name='getCurrentWeather')
            sensor.addFunction(function)
            function = espml.function(name='get10DayForecast')
            sensor.addFunction(function)
            function = espml.function(name='getHourlyForecast')
            sensor.addFunction(function)

            platform.addSensor(sensor)
            field.addPlatform(platform)

        espmlDocXml = StringIO.StringIO()
        system.export(espmlDocXml, 0)

        print espmlDocXml.getvalue()
Beispiel #2
0
    def __init__(self):

        system = espml.system()
        system.setId('http://128.97.93.154:9081')

        f = file('geozip.txt')
        oldState = ''
        cnt = 1
        for line in f:
            splitLine = line.split()

            state = splitLine[0][0:2]
            if state not in ('CA', 'MS', 'GA', 'TX', 'CT', 'NV', 'AZ'):
                continue
            try:
                zipCode = int(splitLine[0][2:])
            except (ValueError, IndexError):
                continue
            lattitude = splitLine[-2]
            longitude = splitLine[-1]

            p = espml.point('%s, %s, 0'%(lattitude, longitude))
            l = espml.location(point=[p])
            if not (oldState == state):
                oldState = state
                field = espml.field(id=cnt, description=state)
                field.setLocation(l)
                system.addField(field)
                cnt += 1
                
            platform = espml.platform(id=zipCode)
            platform.setLocation(l)
            sensor = espml.sensor(id=1, ttype='weather', description='Weather for Zip %d'%(zipCode,))
            sensor.setLocation(l)
            function = espml.function(name='getCurrentWeather')
            sensor.addFunction(function)
            function = espml.function(name='get10DayForecast')
            sensor.addFunction(function)
            function = espml.function(name='getHourlyForecast')
            sensor.addFunction(function)
            
            platform.addSensor(sensor)
            field.addPlatform(platform)

        espmlDocXml = StringIO.StringIO()
        system.export(espmlDocXml, 0)

        print espmlDocXml.getvalue()
Beispiel #3
0
        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>"
Beispiel #4
0
    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>"