Exemplo n.º 1
0
 def index(self):
     self.flat = Flat()
     self.flat.addRoom("1")
     room = self.flat.getRoom("1")
     lock = Lock("3")
     door = Door("2", lock)
     curtain = Curtain("4")
     room.addDoor(door)
     room.addCurtain(curtain)
     return open('html/home.html')
Exemplo n.º 2
0
class Root:

    @cherrypy.expose
    def index(self):
        self.flat = Flat()
        self.flat.addRoom("1")
        room = self.flat.getRoom("1")
        lock = Lock("3")
        door = Door("2", lock)
        curtain = Curtain("4")
        room.addDoor(door)
        room.addCurtain(curtain)
        return open('html/home.html')
        
    @cherrypy.expose
    def testled(self):
        json = getJSON()
        red = json.get("red")
        green = json.get("green")
        blue = json.get("blue")
        # execute lib interfacing with Gadgeteer
        
        # --------------------------------------
        setJSONHeader()
        return simplejson.dumps({'red': red, 'green': green, 'blue': blue});
    
    @cherrypy.expose
    def areasprototype(self):
        setJSONHeader()
        s = self.flat.getState()
        print s
        return s

    @cherrypy.expose
    def areasall(self):
        setJSONHeader()
        return mockJSON
    
    @cherrypy.expose
    def command(self):
        json = getJSON()
        self.flat.parseJSON(json)
        return simplejson.dumps(json);
    
    @cherrypy.expose
    def gadgeteerpost(self):
        pass
Exemplo n.º 3
0
'''
Created on 9 Dec 2012

@author: Kinga
'''
from Room import Room, Door, Lock, Flat, Curtain
from time import sleep

if __name__ == '__main__':

    flat = Flat()
    flat.addRoom(1)
    room = flat.getRoom(1)
    lock = Lock(3)
    door = Door(2, lock)
    curtain = Curtain(4)
    room.addDoor(door)
    room.addCurtain(curtain)

    #print flat.getState()
    print flat.parseJSON("")

    # sleepTime = 10
    # flat = Flat()
    # room = Room(1)
    # flat.addRoom(1)
    # lock = Lock(1)
    # door = Door(1, lock)
    # curtain = Curtain(1)
    # room.addDoor(door)
    # room.addCurtain(curtain)