Example #1
0
class FirefoxConnection(object):
    def __init__(self):
        self.connected = None
        self.loop = MainLoop(protocol_map, self.poke)

    def poke(self):
        print "poking!"
        sublime.set_timeout(self.loop.process, 0)

    def connect(self):
        return defer.maybeDeferred(self._connect)

    def _connect(self):
        if self.connected:
            return self.connected

        # XXX: grab port and hostname from settings maybe?
        self.connected = connect()
        self.connected.addCallback(self._connected)

        self.loop.start()

        return self.connected

    def _connected(self, client):
        print "setting connected to %s" % (self.client,)
        self.client = client
        self.connected = client

    @defer.deferredGenerator
    def choose_tab(self, *args):
        print "choosing tab!"
        d = defer.waitForDeferred(self.client.root.list_tabs())
        yield d
        tabs = d.getResult()
        yield tabs["tabs"][tabs["selected"]]
Example #2
0
 def __init__(self):
     self.connected = None
     self.loop = MainLoop(protocol_map, self.poke)
Example #3
0
def loop():
    from async import MainLoop
    l = MainLoop(protocol_map)
    l.start()
    l.block()