From ed2d5b77cc98dc3bdd684d8ad26ad4f7b0801ae0 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 8 Apr 2016 20:35:45 -0400 Subject: [PATCH] Added datestamp() function --- hue_off.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hue_off.py b/hue_off.py index ccacc31..cb2923f 100755 --- a/hue_off.py +++ b/hue_off.py @@ -107,11 +107,11 @@ def checkPowerOutage(): pwrstatus = commands.getstatusoutput("pwrstat -status | grep 'Power Supply'") if "Utility" not in pwrstatus[1]: # We have a power failure! - print "Mains power: FAILURE" + print "%s:Mains power: FAILURE" % datestamp() return True else: # No power failure... some other problem. Don't touch the lights. - print "Mains power: OK" + print "%s:Mains power: OK" % datestamp() return False def waitSetlights(off_lights,check_interval): @@ -127,6 +127,10 @@ def waitSetlights(off_lights,check_interval): time.sleep(check_interval) return 0 +def datestamp(): + # this function returns a date string formatted as YYYYMMDD-HHMMSS + return strftime("%Y%m%d-%H%M%S", gmtime()) + if __name__ == "__main__": main(sys.argv[1:])