Commit 78343205 authored by kpetersn's avatar kpetersn
Browse files

Use time from xml instead of time.asctime()

parent ca28fe23
......@@ -7,7 +7,8 @@
import urllib
import xml.etree.ElementTree as ET
import time
# for time.asctime()
#!import time
# needed for notifyOSX()
import os
......@@ -18,13 +19,11 @@ engineer = "Peterson"
# period should match cron job period
period = 120
def notifyConsole(ioc, state):
notify_time = time.asctime()
print "[%s] %s is %s" % (notify_time, ioc, state)
def notifyConsole(ioc, state, time_str):
print "[%s] %s is %s" % (time_str, ioc, state)
def notifyOSX(ioc, state):
notify_time = time.asctime()
notify_command = "%s -title \"%s is %s\" -message \"%s\"" % (osx_command, ioc, state, notify_time)
def notifyOSX(ioc, state, time_str):
notify_command = "%s -title \"%s is %s\" -message \"%s\"" % (osx_command, ioc, state, time_str)
os.system(notify_command)
# set notification function
......@@ -47,6 +46,10 @@ f.close()
#!print "Parsing XML"
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
def _indent(elem, level=0):
'''
......@@ -111,4 +114,4 @@ iocs = ioc_list.keys()
iocs.sort()
for ioc in iocs:
notify(ioc, ioc_list[ioc])
notify(ioc, ioc_list[ioc], time_str)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment