def mainloop(name):
    matches = matcher(name)

    @receiver(devicefound)
    def found(sender, **kwargs):
        if matches(sender.name):
            print "Found device:", sender.name

    @receiver(statechange)
    def motion(sender, **kwargs):
        if matches(sender.name):
            print "{} state is {state}".format(
                sender.name, state="on" if kwargs.get('state') else "off")

    env = Environment()
    try:
        env.start()
        env.discover(10)
        env.wait()
    except (KeyboardInterrupt, __HOLE__):
        print "Goodbye!"
        sys.exit(0)
dataset/ETHPy150Open iancmcc/ouimeaux/ouimeaux/examples/watch.py/mainloop