Changeset 687 in tmcsimulator for trunk/src/python/unifiedlogger/har_watcher.py


Ignore:
Timestamp:
10/02/2022 10:32:42 AM (4 years ago)
Author:
jdalbey
Message:

logging_service.py, et.al. Revise how it handles a missing CADcomments.log file - just skip the file read but continue. Also update all watchers to use config dir.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/python/unifiedlogger/har_watcher.py

    r649 r687  
    1 import json, time 
     1import json, time, ConfigParser 
    22from copy import deepcopy 
    33 
     
    99currList = []  # current messages 
    1010locationMap = {} # map of HAR ID's to locations 
     11filepath = "webapps/dynamicdata" # default during development 
    1112 
    1213# Utility functions 
     
    1718 
    1819# Read the har message file 
    19 def readFile():      
    20      with open ("webapps/dynamicdata/har_messages.json",'r') as myfile: 
     20def readFile(): 
     21    global filepath 
     22    with open (filepath+"/har_messages.json",'r') as myfile: 
    2123          jsonData=myfile.read() 
    2224  
    23      return json.loads(jsonData)['data'] 
     25    return json.loads(jsonData)['data'] 
    2426 
    2527# Read the static file of cms locations and create a lookup map 
     
    5153          currList.append(aMessage.replace("\n"," ").strip()) 
    5254 
    53 def setup(): 
    54      extractMessages(initialize()) 
     55def setup(dir): 
     56    global filepath 
     57    # get path to input file from configuration 
     58    config = ConfigParser.ConfigParser() 
     59    config.read(dir+'/logging_service.cfg') 
     60    filepath  = config.get('Paths', 'UnifiedLogPath') 
     61 
     62    extractMessages(initialize()) 
    5563 
    5664# compare previous messages to current messages to look for changes 
     
    8189def main(): 
    8290     global currList 
    83      setup() 
     91     setup("config/devlinux") 
    8492     # Loop Forever 
    8593     while True: 
Note: See TracChangeset for help on using the changeset viewer.