Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(1)  |  Call(1)  |  Derive(0)  |  Import(0)

        def getArduinoTemp(ip_addr, port, timeout, retry):
	for i in range(retry):
		try:
			#conn = http.client.HTTPConnection(ip_addr, port, timeout)
			conn = httplib.HTTPConnection(ip_addr, port, timeout)
			conn.request("GET", "/temp")
			conn.sock.settimeout(timeout)
			r1 = conn.getresponse()
			if (r1.status == 200):
				lines = r1.read()
				line = lines.split('\n')
				temp = None
				if (len(lines.split()) == 3):
					temp = float(line[2])
				if (temp == ARDUINO_NOT_READY):
					temp = None
				else:
					break
			else:
				print (r1.status, r1.reason)
				temp = None
	
		except:
			print (strftime("[%H:%M:%S]: EXCEPTION ", localtime()) + str(sys.exc_info()[0]))
			temp = None
			sleep(2)	#wait for device to get ready again
		
	conn.close()

	return temp
        


src/h/o/HomeCoolingPi-HEAD/PostTemperature/PostTemperature.py   HomeCoolingPi(Download)
 
	#Get Arduino temp
	curArduinoTemp = Arduino_Temp.getArduinoTemp(arduino_ip_addr, arduino_port, arduino_tmo, arduino_retry)
	if (curArduinoTemp):
		print (strftime("[%H:%M:%S]: ", localtime()) + "Attic Temp\t" + str(curArduinoTemp))