Browse code

minor revisions

Gandolf authored on 07/09/2021 23:35:12
Showing 1 changed files
... ...
@@ -38,6 +38,8 @@
38 38
 #     status page and parsed the signal data from the html.
39 39
 #   * v23 released 11 Jun 2021 by J L Owrey; remove unused code.
40 40
 #   * v24 released 14 Jun 2021 by J L Owrey; minor revisions
41
+#   * v25 released 9 Jul 2021 by J L Owrey; improved handling of
42
+#         node status function
41 43
 #
42 44
 #2345678901234567890123456789012345678901234567890123456789012345678901234567890
43 45
 
... ...
@@ -59,7 +61,8 @@ _SERVER_MODE = "primary"
59 61
 
60 62
 # set url of the aredn node
61 63
 
62
-_DEFAULT_AREDN_NODE_URL = "{your AREDN mesh node url"
64
+_DEFAULT_AREDN_NODE_URL = \
65
+    "{your node url}"
63 66
 
64 67
     ### FILE AND FOLDER LOCATIONS ###
65 68
 
... ...
@@ -101,7 +104,7 @@ debugMode = False
101 104
 # count of failed attempts to get data from aredn node
102 105
 failedUpdateCount = 0
103 106
 # detected status of aredn node device
104
-nodeOnline = True
107
+nodeOnline = False
105 108
 
106 109
 # ip address of aredn node
107 110
 arednNodeUrl = _DEFAULT_AREDN_NODE_URL
... ...
@@ -165,10 +168,8 @@ def terminateAgentProcess(signal, frame):
165 168
            signal, frame - dummy parameters
166 169
        Returns: nothing
167 170
     """
168
-    # Inform downstream clients by removing output data file.
169
-    if os.path.exists(_OUTPUT_DATA_FILE):
170
-       os.remove(_OUTPUT_DATA_FILE)
171 171
     print('%s terminating arednsig agent process' % getTimeStamp())
172
+    setStatusToOffline()
172 173
     sys.exit(0)
173 174
 ##end def
174 175
 
... ...
@@ -183,12 +184,8 @@ def getNodeData(dData):
183 184
     """
184 185
     try:
185 186
         currentTime = time.time()
186
-
187 187
         response = urlopen(arednNodeUrl, timeout=_HTTP_REQUEST_TIMEOUT)
188
-
189
-        if verboseMode:
190
-            requestTime = time.time() - currentTime
191
-            print("http request: %.4f seconds" % requestTime)
188
+        requestTime = time.time() - currentTime
192 189
 
193 190
         content = response.read().decode('utf-8')
194 191
         content = content.replace('\n', '')
... ...
@@ -206,9 +203,10 @@ def getNodeData(dData):
206 203
 
207 204
     if debugMode:
208 205
         print(content)
206
+    if verboseMode:
207
+        print("http request successful: %.4f sec" % requestTime)
209 208
 
210 209
     dData['content'] = content
211
-
212 210
     return True
213 211
 ##end def
214 212
 
... ...
@@ -237,14 +235,19 @@ def parseDataString(dData):
237 235
         snr = snr.replace(' ','')
238 236
         lsnr = snr.split('/')
239 237
 
240
-        dData['time'] = getEpochSeconds(getTimeStamp())
241 238
         dData['signal'] = lsnr[0]
242 239
         dData['noise'] = lsnr[1]
243 240
         dData['snr'] = lsnr[2]
244
-    
245 241
     except Exception as exError:
246 242
         print("%s parse failed: %s" % (getTimeStamp(), exError))
247 243
         return False
244
+    ## end try
245
+
246
+    # Add status information to dictionary object.
247
+    dData['date'] = getTimeStamp()
248
+    dData['chartUpdateInterval'] = chartUpdateInterval
249
+    dData['dataRequestInterval'] = dataRequestInterval
250
+    dData['serverMode'] = _SERVER_MODE
248 251
 
249 252
     return True
250 253
 ##end def
... ...
@@ -262,16 +265,12 @@ def writeOutputFile(dData):
262 265