Changeset 689 in tmcsimulator for trunk/src/python


Ignore:
Timestamp:
10/02/2022 01:23:27 PM (4 years ago)
Author:
jdalbey
Message:

cad_watcher.py Enhance to deal with system restart during logging session.

File:
1 edited

Legend:

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

    r687 r689  
    3232    except IOError as ex: 
    3333        if ex.errno == 2: 
    34             # 'No such file or directory' 
    35             # Assume this is a read sync problem: Don't modify lastLineNum 
     34            # 'No such file or directory' - could be system was restarted or 
     35            # this is a read sync problem: Don't modify lastLineNum 
    3636            print pathToLog + " missing, skipping file read." 
    3737            #lastLineNum = 0   #Start over 
     
    4545        fileSize = os.path.getsize(pathToLog) 
    4646        if fileSize == 0: 
    47             print pathToLog+" is empty, skipping file read and resetting." 
    48             lastLineNum = 0   #Start over 
     47            # Assume this is a read sync problem: Don't modify lastLineNum 
     48            # because once the file is synced it will have same # of lines. 
     49            print pathToLog+" is empty, skipping file read." 
     50            #lastLineNum = 0   #Start over 
    4951            return [] 
    5052        else: # file is good, read it. 
     
    5254            text_file.close() 
    5355            currList = [] 
     56            # If the system restarted there is usually fewer lines in the file 
     57            # than lastLineNum, so assume all lines are new and reset lastLineNum 
     58            if len(msgList) < lastLineNum: 
     59                print pathToLog + " has few lines than expected, assuming restart." 
     60                lastLineNum = 0 
    5461            currList = msgList[lastLineNum:] # new items since last file read 
    5562            lastLineNum = len(msgList) 
Note: See TracChangeset for help on using the changeset viewer.