Changeset 687 in tmcsimulator for trunk/src/python/unifiedlogger/cad_watcher.py
- Timestamp:
- 10/02/2022 10:32:42 AM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/python/unifiedlogger/cad_watcher.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/python/unifiedlogger/cad_watcher.py
r522 r687 11 11 12 12 lastLineNum = 0 13 configdir = "config" # default dir for production 13 14 14 def setup(): 15 def setup(dir): 16 global lastLineNum, configdir 15 17 lastLineNum = 0 18 configdir = dir 16 19 return 17 20 18 21 # Retrieve new messages from CAD comment log 19 22 def getLogEntries(): 20 global lastLineNum 23 global lastLineNum, configdir 21 24 # get path to input file from configuration 22 25 config = ConfigParser.ConfigParser() 23 config.read( 'config/logging_service.cfg')26 config.read(configdir+'/logging_service.cfg') 24 27 logfilepath = config.get('Paths', 'UnifiedLogPath') 25 28 pathToLog = logfilepath + "CADcomments.log" … … 29 32 except IOError as ex: 30 33 if ex.errno == 2: 31 # 'No such file or directory 32 print pathToLog + " missing: assuming reset." 33 lastLineNum = 0 #Start over 34 # 'No such file or directory' 35 # Assume this is a read sync problem: Don't modify lastLineNum 36 print pathToLog + " missing, skipping file read." 37 #lastLineNum = 0 #Start over 34 38 return [] 35 39 else: … … 41 45 fileSize = os.path.getsize(pathToLog) 42 46 if fileSize == 0: 43 # Assume this is a read sync problem: Don't modify lastLineNum 44 print pathToLog+" is empty, ignoring." 47 print pathToLog+" is empty, skipping file read and resetting." 45 48 lastLineNum = 0 #Start over 46 49 return [] 47 50 else: # file is good, read it. 48 msgList = text_file.read().s plit('\n')51 msgList = text_file.read().strip().split('\n') 49 52 text_file.close() 50 53 currList = [] 51 54 currList = msgList[lastLineNum:] # new items since last file read 52 lastLineNum = len(msgList) -155 lastLineNum = len(msgList) 53 56 return currList 54 57 55 58 # Local main for unit testing 56 59 def main(): 57 setup( )60 setup("config/devlinux") 58 61 # Loop Forever, checking every five seconds 59 62 while True:
Note: See TracChangeset
for help on using the changeset viewer.
