Browse code

bug fix

gandolf authored on 02/13/2020 22:20:44
Showing 1 changed files
... ...
@@ -30,6 +30,9 @@
30 30
 #
31 31
 # Revision History
32 32
 #   * v20 released 11 Jan 2020 by J L Owrey; first release
33
+#   * v21 released 13 Feb 2020 by J L Owrey; fixed bug occuring when node
34
+#     powers on and signal data memory is empty.  Data points with N/A data
35
+#     are discarded.
33 36
 #
34 37
 #2345678901234567890123456789012345678901234567890123456789012345678901234567890
35 38
 
... ...
@@ -51,7 +54,7 @@ _HOSTNAME = os.uname()[1]
51 54
 
52 55
 _DEFAULT_AREDN_NODE_URL = "http://localnode:8080/cgi-bin/signal.json"
53 56
 
54
-if _HOSTNAME == "{my alternate host}": 
57
+if _HOSTNAME == "raspi2": 
55 58
     _DEFAULT_AREDN_NODE_URL = "http://192.168.1.30:8080/cgi-bin/signal.json"
56 59
 
57 60
     ### FILE AND FOLDER LOCATIONS ###
... ...
@@ -222,7 +225,8 @@ def parseNodeData(sData, ldData):
222 225
         ldTmp = json.loads(sData[1:-1])
223 226
         ldTmp = ldTmp[-iTrail:]
224 227
         if len(ldTmp) != iTrail:
225
-            raise Exception("truncated list")
228
+            #raise Exception("truncated list")
229
+            pass
226 230
     except Exception, exError:
227 231
         print "%s parse failed: %s" % (getTimeStamp(), exError)
228 232
         return False
... ...
@@ -247,7 +251,9 @@ def convertData(ldData):
247 251
     #  u'label': u'01/10/2020 22:17:01', u'rx_rate': u'130',
248 252
     #  u'y': [-48, -95], u'x': 1578694621000, u'tx_rate': u'130'}
249 253
     #
250
-    for item in ldData:
254
+    index = 0
255
+    while index < len(ldData):
256
+        item = ldData[index]
251 257
         try:
252 258
             item['time'] = int(item.pop('x')) / 1000
253 259
             item['signal'] = int(item['y'][0])
... ...
@@ -260,12 +266,21 @@ def convertData(ldData):
260 266
             item.pop('y')
261 267
             item.pop('label')
262 268
         except Exception, exError:
263
-            print "%s convert data failed: %s" % (getTimeStamp(), exError)
264
-            return False
269
+            print "%s convert data item failed: %s" % (getTimeStamp(), exError)
270
+            print "discarding %s" % item
271
+            #return False
272
+            ldData.pop(index)
273
+        else:
274
+            index += 1
265 275
     ##end for
266
-    if verboseDebug:
267
-        print "convert data successful"
268
-    return True
276
+
277
+    if len(ldData) > 0:
278
+        if verboseDebug:
279
+            print "convert data successful"
280
+        return True
281
+    else:
282
+        print "convert data failed"
283
+        return False
269 284
 ##end def
270 285
 
271 286
 def updateDatabase(ldData):