Exemplo n.º 1
0
#! /usr/bin/env python
#
# Created by Philipp Mayr on 27. June, 2013 (Germany)
#
# Name: portmapper.py
#
# License: CC NY-NC
#

from core.elvipio88 import elvipio88 as iodevice

if __name__ == "__main__":
    
    io = iodevice()
    state = io.getport()
    
    print ("Ports 0-8 are 'IN' ports and 9-16 are 'OUT' ports")
    
    for port in range(16):
        print ("Port "+str(port)+" state is "+str(state[port]))
class iTunes: # iTunes controll Object
    State = "osascript -e \'tell application \"iTunes\" to player state as string\'"
    Play = "osascript -e \'tell application \"iTunes\" to play\'"
    Pause = "osascript -e \'tell application \"iTunes\" to pause\'"
    
    def pause(self):
        os.system(self.Pause)
    
    def play(self):
        os.system(self.Play)



if __name__ == "__main__":
    
    io = iodevice("192.168.1.100")
    iTunes = iTunes()
    
    print OMU.Info,"Started at ",time.ctime(),OMU.EndSig
    print OMU.Info,"using this address: ",io.address," for the IO",OMU.EndSig
    
    try:
        while 1:
            portstate = io.getport()
            
            if portstate[0] == True:
                iTunes.play()
            elif portstate[0] == False:
                iTunes.pause()
            
            time.sleep(30)