Changeset 687 in tmcsimulator for trunk/src/python/unifiedlogger/cms_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/cms_watcher.py

    r549 r687  
    1 import json, time 
     1import json, time, ConfigParser 
    22from copy import deepcopy 
    33 
     
    99currList = []  # current messages 
    1010locationMap = {} # map of CMS ID's to locations 
     11filepath = "webapps/dynamicdata" # default during development 
    1112 
    1213# Utility functions 
     
    1718 
    1819# Read the cms message file 
    19 def readFile():      
    20      with open ("webapps/dynamicdata/cms_messages.json",'r') as myfile: 
     20def readFile(): 
     21    global filepath 
     22    with open (filepath+"/cms_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 
     
    5658                    msgList[idx]['cms']['message']['phase2']['Line3']) 
    5759 
    58 def setup(): 
    59      extractMessages(initialize()) 
     60def setup(dir): 
     61    global filepath 
     62    # get path to input file from configuration 
     63    config = ConfigParser.ConfigParser() 
     64    config.read(dir+'/logging_service.cfg') 
     65    filepath  = config.get('Paths', 'UnifiedLogPath') 
     66    
     67    extractMessages(initialize()) 
    6068 
    6169# compare previous messages to current messages to look for changes 
     
    8694def main(): 
    8795     global currList 
    88      setup() 
     96     setup("config/devlinux") 
    8997     # Loop Forever 
    9098     while True: 
Note: See TracChangeset for help on using the changeset viewer.