Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions snotparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<to_line>.*)$", 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<cc_line>.*)$", 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<boogerd_uuid_line>.*)$", line)
if match:
ticketDictionary["boogerd_uuid"] = match.group("boogerd_uuid_line")
break

for line in rawTicket[administrativeStartLine:]:
kvMatch = re.match("^(?P<key>.+?):\s+(?P<value>.*)$", line)
if kvMatch:
Expand Down Expand Up @@ -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':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is in the config as
snot:
logfile:

Maybe pass it into the function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you describe the object i should be passing in a bit better? I don't really understand what to pass in from this message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we just pass in the logfile?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having an argument for the logfile would be appropriate, with a default value of the production logfile.

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)
Expand All @@ -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)