Skip to content
Snippets Groups Projects
Commit 78343205 authored by kpetersn's avatar kpetersn
Browse files

Use time from xml instead of time.asctime()

parent ca28fe23
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
import urllib import urllib
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import time # for time.asctime()
#!import time
# needed for notifyOSX() # needed for notifyOSX()
import os import os
...@@ -18,13 +19,11 @@ engineer = "Peterson" ...@@ -18,13 +19,11 @@ engineer = "Peterson"
# period should match cron job period # period should match cron job period
period = 120 period = 120
def notifyConsole(ioc, state): def notifyConsole(ioc, state, time_str):
notify_time = time.asctime() print "[%s] %s is %s" % (time_str, ioc, state)
print "[%s] %s is %s" % (notify_time, ioc, state)
def notifyOSX(ioc, state): def notifyOSX(ioc, state, time_str):
notify_time = time.asctime() notify_command = "%s -title \"%s is %s\" -message \"%s\"" % (osx_command, ioc, state, time_str)
notify_command = "%s -title \"%s is %s\" -message \"%s\"" % (osx_command, ioc, state, notify_time)
os.system(notify_command) os.system(notify_command)
# set notification function # set notification function
...@@ -47,6 +46,10 @@ f.close() ...@@ -47,6 +46,10 @@ f.close()
#!print "Parsing XML" #!print "Parsing XML"
root = ET.fromstring(xml_string) root = ET.fromstring(xml_string)
# Get the date and time
time_elem = root.find('time')
time_str = time_elem.text
# Indent for making ET.tostring() output readable # Indent for making ET.tostring() output readable
def _indent(elem, level=0): def _indent(elem, level=0):
''' '''
...@@ -111,4 +114,4 @@ iocs = ioc_list.keys() ...@@ -111,4 +114,4 @@ iocs = ioc_list.keys()
iocs.sort() iocs.sort()
for ioc in iocs: for ioc in iocs:
notify(ioc, ioc_list[ioc]) notify(ioc, ioc_list[ioc], time_str)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment