- Timestamp:
- 12/18/2019 01:53:04 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/python/unifiedlogger/extend_unifiedlogger.py
r542 r544 1 1 import xml.etree.ElementTree as ET 2 2 import os, ConfigParser 3 4 3 5 4 config = ConfigParser.ConfigParser() … … 8 7 9 8 # read in the incident script in XML format 10 tree = ET.parse(logfilepath + 'incident_script .xml')9 tree = ET.parse(logfilepath + 'incident_script_test.xml') 11 10 # root is TMC_SCRIPT tag 12 11 root = tree.getroot() … … 40 39 # Look for CAD_INCIDENT_EVENT 41 40 if event.tag == 'CAD_INCIDENT_EVENT': 42 # count variable make sure there is as least a field 43 # inside CAD_INCIDENT_EVENT 44 count = 0 41 # set flag to check if DETAIL field exist 42 detail = False 45 43 for info in event: 46 count += 1 47 # Aad the incident detail to entry string 44 # Add the incident detail to entry string 48 45 if info.tag == "DETAIL": 49 entry_str += ", Detail: " + info.text 50 else: 51 # if no detail found then reset string 52 entry_str = "" 53 # if no field inside CAD_INCIDENT_EVENT 54 # reset the string 55 if count == 0: 56 entry_str = "" 46 # replace commas with whitespace 47 text = info.text.replace(",", " ") 48 # if it's not the first DETAIL field, 49 # append to the end without "Detail" text 50 if detail: 51 entry_str += "; " + text 52 else: 53 entry_str += ", Detail: " + text 54 detail = True 57 55 58 # if entry_str contain some info56 # if there's detail field 59 57 # add it to the entries 60 if entry_str != "":58 if detail: 61 59 entries += entry_str + "\n" 62 60 # write all the entries from incident_sript.xml to the output file … … 75 73 os.system("sort -o " + logfilepath + "caddetails.csv " \ 76 74 + logfilepath + "caddetails.csv") 75
Note: See TracChangeset
for help on using the changeset viewer.
