Changeset 439 in tmcsimulator for trunk/webapps/unifiedlogger/logging_service.py
- Timestamp:
- 07/11/2019 02:45:25 PM (7 years ago)
- File:
-
- 1 edited
-
trunk/webapps/unifiedlogger/logging_service.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/webapps/unifiedlogger/logging_service.py
r433 r439 1 import cms_watcher, cad_watcher, time, json 1 import cms_watcher, cad_watcher, time, json, ConfigParser 2 2 # Unified Logging Service 3 3 # jdalbey 7/6/2019 4 4 5 outputFilename = "unifiedlog.csv" 5 6 6 7 # Load the sim time file and extract the seconds */ 7 8 def getSimTime(): 8 with open (" ../dynamicdata/sim_elapsedtime.json", 'r') as myfile:9 with open ("webapps/dynamicdata/sim_elapsedtime.json", 'r') as myfile: 9 10 jsonData=myfile.read() 10 11 … … 15 16 return "%d:%02d:%02d" % (h, m, s) 16 17 17 def main(): 18 def startup(): 19 # get path to output file from configuration 20 config = ConfigParser.ConfigParser() 21 config.read('config/logging_service.cfg') 22 logfilepath = config.get('Paths', 'UnifiedLogPath') 23 18 24 # Delete any previously existing output file 19 f = open("../dynamicdata/unifiedlog.html", "w") 20 startHTML = "<HTML><HEAD><meta http-equiv=\"refresh\" content=\"5\" /></HEAD><BODY><PRE>" 21 f.write(startHTML); 25 f = open(logfilepath + outputFilename, "w") 22 26 f.close() 23 27 # List of the available plugin modules … … 51 55 trimmed_item = item.strip() 52 56 if len(trimmed_item) > 0: 53 output += timeStamp + " " + trimmed_item + "\n"57 output += timeStamp + ", " + trimmed_item + "\n" 54 58 # END LOOP 55 59 # IF the Output Buffer has any contents THEN 56 60 if len(output) > 0: 57 # Write (append) Output Buffer to unified log file 61 # Write (append) Output Buffer to unified log file as CSV 62 # Assumes fields don't contain commas 58 63 print output, 59 f = open( "../dynamicdata/unifiedlog.html", "a")64 f = open(logfilepath + outputFilename, "a") 60 65 f.write(output) 61 66 f.close() 62 67 # END IF 63 # Wait one second64 time.sleep( 1)68 # Wait five seconds 69 time.sleep(5) 65 70 66 71 #END DO 67 if __name__ == "__main__": 68 main() 72 73 if __name__ == '__main__': 74 startup()
Note: See TracChangeset
for help on using the changeset viewer.
