fix(exec/temp):Reduce socket calls for hostname
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Tue, 27 Oct 2020 19:00:05 +0000 (19:00 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Tue, 27 Oct 2020 19:00:05 +0000 (19:00 +0000)
exec/temperature/DS18B20..temp_poll.py

index f15926cba44ed727d8b3120436e079b43b6ab74c..831e4aa2593ec0912607278c910cbdd482088fd0 100755 (executable)
@@ -33,10 +33,12 @@ def read_temp():
         #return temp_c, temp_f
         return temp_c_2dec
 
+
+myHostname = socket.gethostname()
+
 while True:
     nowTimeIso8601 = strftime("%Y%m%dT%H%M%S%z")
     nowTimeUE = strftime("%s")
     nowTemp = read_temp()
-    myHostname = socket.gethostname()
     print(str(nowTimeIso8601) + ',' + str(nowTimeUE) + ',' + str(myHostname) + ',' + str(nowTemp))
     time.sleep(1)