diff --git a/snotparser.py b/snotparser.py index 8dcfca6..a5720cc 100755 --- a/snotparser.py +++ b/snotparser.py @@ -52,6 +52,27 @@ def parseTicket(number, command='snot'): ticketDictionary["from_line"] = match.group("from_line") break + #print "Searching for To field" + for line in rawTicket[0:bodyStartLine]: + match = re.match(r"^To:\s*(?P.*)$", line) + if match: + ticketDictionary["to_line"] = match.group("to_line") + break + + #print "Searching for cc field" + for line in rawTicket[0:bodyStartLine]: + match = re.match(r"^Cc:\s*(?P.*)$", line) + if match: + ticketDictionary["cc_line"] = match.group("cc_line") + break + + #print "Searching for X-Boogerd-UUID field" + for line in rawTicket[0:bodyStartLine]: + match = re.match(r"^X-Boogerd-UUID:\s*(?P.*)$", line) + if match: + ticketDictionary["boogerd_uuid"] = match.group("boogerd_uuid_line") + break + for line in rawTicket[administrativeStartLine:]: kvMatch = re.match("^(?P.+?):\s+(?P.*)$", line) if kvMatch: @@ -130,10 +151,14 @@ def formatTicketSmart(number, formatString, command='snot'): return str(number) + ": No ticket found" -def getTicketHistory(number): +def getTicketHistory(number, snot_cmd): try: number = int(number) - process = subprocess.Popen(['grep', "TKT: %d" % number, "/u/snot/logs/log"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + if snot_cmd == 'testsnot': + snot_log = '/u/snot/test/logs/log' + else: + snot_cmd = '/u/snot/logs/log' + process = subprocess.Popen(['grep', "TKT: %d" % number, snot_log], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) return process.stdout.readlines() except ValueError as e: return str(e) @@ -145,3 +170,4 @@ def getTicketHistory(number): snot_cmd = os.environ.get('SNOT_CMD', 'snot') ticket_num = sys.argv[1] print ticket_num, parseTicket(ticket_num, snot_cmd) + #print ticket_num, getTicketHistory(ticket_num, snot_cmd)