Exemple #1
0
def executeRemoteCommand(command):
    result = True
    
    if command == REMOTE_LOCK:
        if hardwareconfig.checkLock() == False:
            AFroutines.lockScreen()
            result = sendemail.sendEmail("Command successful","Screen locked")
            eventQueue.put(("Log",'Screen locked due to remote command'))
        else:
            eventQueue.put(("Log",'Lock screen failed - command received while locked'))
            result = sendemail.sendEmail("Command failed","Screen already locked")
            
    elif command == REMOTE_STARTMONITOR:
        #cant check ispy camera status, just have to assume it was not monitoring
        iSpyPath = fileconfig.config.get('TRIGGERS','ispy_path')
        roomCamID = fileconfig.config.get('TRIGGERS','room_cam_id')
        if os.path.exists(iSpyPath):
            eventQueue.put(("Log","Starting room camera due to remote command"))
        else:
            eventQueue.put(("Log","iSpy executable not found - cannot fulfill remote command"))
            return
        
        subprocess.call([iSpyPath,'commands bringonline,2,%s'%roomCamID])
        result = sendemail.sendEmail("Command successful","Movement monitoring initiated. Have a nice day.")
        
    elif command == REMOTE_STOPMONITOR:
        #cant check ispy camera status, just have to assume it was already monitoring
        iSpyPath = fileconfig.config.get('TRIGGERS','ispy_path')
        roomCamID = fileconfig.config.get('TRIGGERS','room_cam_id')
        if os.path.exists(iSpyPath):
            eventQueue.put(("Log","Stopping room camera due to remote command"))
        else:
            eventQueue.put(("Log","iSpy executable not found - cannot fulfill remote command"))
            return
            
        subprocess.call([iSpyPath,'commands takeoffline,2,%s'%roomCamID])
        result = sendemail.sendEmail("Command successful","Movement monitoring disabled. Welcome home!")
        
    elif command == REMOTE_SHUTDOWN:
        result = sendemail.sendEmail("Command successful","Shutting down...")
        eventQueue.put(("Log","Initiating standard shutdown due to remote command"))
        AFroutines.standardShutdown()
        
    elif command == REMOTE_KILLSWITCH:
        eventQueue.put(("Log","Initiating emergency shutdown due to remote command"))
        AFroutines.emergency()
        
    if result != True: eventQueue.put(('Log','Mail send failed: %s'%result))
def executeRemoteCommand(command):
    result = True

    if command == REMOTE_LOCK:
        if hardwareconfig.checkLock() == False:
            AFroutines.lockScreen()
            result = sendemail.sendEmail("Command successful", "Screen locked")
            eventQueue.put(("Log", 'Screen locked due to remote command'))
        else:
            eventQueue.put(
                ("Log", 'Lock screen failed - command received while locked'))
            result = sendemail.sendEmail("Command failed",
                                         "Screen already locked")

    elif command == REMOTE_STARTMONITOR:
        #cant check ispy camera status, just have to assume it was not monitoring
        iSpyPath = fileconfig.config.get('TRIGGERS', 'ispy_path')
        roomCamID = fileconfig.config.get('TRIGGERS', 'room_cam_id')
        if os.path.exists(iSpyPath):
            eventQueue.put(
                ("Log", "Starting room camera due to remote command"))
        else:
            eventQueue.put(
                ("Log",
                 "iSpy executable not found - cannot fulfill remote command"))
            return

        subprocess.call([iSpyPath, 'commands bringonline,2,%s' % roomCamID])
        result = sendemail.sendEmail(
            "Command successful",
            "Movement monitoring initiated. Have a nice day.")

    elif command == REMOTE_STOPMONITOR:
        #cant check ispy camera status, just have to assume it was already monitoring
        iSpyPath = fileconfig.config.get('TRIGGERS', 'ispy_path')
        roomCamID = fileconfig.config.get('TRIGGERS', 'room_cam_id')
        if os.path.exists(iSpyPath):
            eventQueue.put(
                ("Log", "Stopping room camera due to remote command"))
        else:
            eventQueue.put(
                ("Log",
                 "iSpy executable not found - cannot fulfill remote command"))
            return

        subprocess.call([iSpyPath, 'commands takeoffline,2,%s' % roomCamID])
        result = sendemail.sendEmail(
            "Command successful",
            "Movement monitoring disabled. Welcome home!")

    elif command == REMOTE_SHUTDOWN:
        result = sendemail.sendEmail("Command successful", "Shutting down...")
        eventQueue.put(
            ("Log", "Initiating standard shutdown due to remote command"))
        AFroutines.standardShutdown()

    elif command == REMOTE_KILLSWITCH:
        eventQueue.put(
            ("Log", "Initiating emergency shutdown due to remote command"))
        AFroutines.emergency()

    if result != True: eventQueue.put(('Log', 'Mail send failed: %s' % result))