#!/usr/bin/python __author__ = 'Royce' import os import logging from time import sleep from libs.LifxControl import LifxControl #logging.captureWarnings(True) Control = LifxControl() auth_log = '/var/log/auth.log' def tail(f, n): stdin, stdout = os.popen2("tail -n " + str(n) + " " + f + "|grep closed") stdin.close() lines = stdout.readlines() stdout.close() return lines monitoring = True ip = [] while monitoring: sleep(5) auth_tail = tail(auth_log, 1) print auth_tail if auth_tail: if ip:
__author__ = 'Royce' import logging from libs.LifxControl import LifxControl logging.captureWarnings(True) Control = LifxControl() try: #Control.allOn() Control.listLights() Control.pulseAll() #Control.allOff() #Control.listScenes() #Control.activateScene() #Control.listLights() except Exception as e: print e
#!/usr/bin/python __author__ = "Royce" import os import logging from time import sleep from libs.LifxControl import LifxControl # logging.captureWarnings(True) Control = LifxControl() auth_log = "/var/log/auth.log" def tail(f, n): stdin, stdout = os.popen2("tail -n " + str(n) + " " + f + "|grep closed") stdin.close() lines = stdout.readlines() stdout.close() return lines monitoring = True ip = [] while monitoring: sleep(5) auth_tail = tail(auth_log, 1) print auth_tail if auth_tail: if ip:
#!/usr/bin/python __author__ = 'Royce' import logging import sys from libs.LifxControl import LifxControl power = "" if len(sys.argv) != 2: print(" python {} <on/off>\n".format(sys.argv[0])) else: power = sys.argv[1] logging.captureWarnings(True) Control = LifxControl() if power == "off": try: Control.allOff() except Exception as e: print e elif power == "on": try: Control.allOn() except Exception as e: print e