Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(40)  |  Call(40)  |  Derive(0)  |  Import(0)

src/a/s/astral-HEAD/astral/node/base.py   astral(Download)
    def node(self):
        return Node.get_by(uuid=self.uuid) or Node.me(uuid_override=self.uuid)
 
    def _unregister_from_origin(self):
        if self.node().supernode:
    def _cancel_tickets(self):
        for ticket in Ticket.query.filter_by(source=Node.me()).filter(
                Ticket.destination != Node.me()):
            log.info("Cancelling %s", ticket)
            if ticket.destination:
                TicketsAPI(ticket.destination.uri()).cancel(ticket.absolute_url())
 
        for ticket in Ticket.query.filter_by(destination=Node.me()).filter(
                Ticket.source != Node.me()):

src/a/s/astral-HEAD/astral/node/bootstrap.py   astral(Download)
    def prime_stream_tunnels(self):
        for stream in Stream.query.filter(Stream.source == Node.me()):
            stream.queue_tunnel_status_flip()
 
    def register_with_origin(self):
            self.register_with_origin()
            for supernode in Node.supernodes():
                if supernode != Node.me():
                    try:
                        NodesAPI(supernode.uri()).register(
    def run(self):
        UpstreamCheckThread(self.node, self.upstream_limit).run()
        Node.me(refresh=True)
        self.load_static_bootstrap_nodes()
        self.load_dynamic_bootstrap_nodes()

src/a/s/astral-HEAD/astral/api/handlers/tickets.py   astral(Download)
    def _already_seeding(cls, ticket):
        return Node.me() in [ticket.destination, ticket.stream.source]
 
    @classmethod
    def _offer_ourselves(cls, stream, destination):
        tickets = Ticket.query.filter_by(source=Node.me())
            raise HTTPError(412)
 
        ticket = Ticket.get_by(stream=stream, destination=Node.me())
        if ticket:
            new_ticket = Ticket(stream=stream, destination=destination,
    def _request_stream_from_node(cls, stream, node, destination,
            existing_ticket=None):
        if not node or node == Node.me() or node == destination:
            return
        log.info("Requesting %s from the node %s, to be delivered to %s",
    def _request_stream_from_supernodes(cls, stream, destination,
            unconfirmed_tickets=None):
        tickets = []
        for supernode in Node.supernodes():
            if supernode != Node.me() and not cls._already_ticketed(

src/a/s/astral-HEAD/astral/api/handlers/ticket.py   astral(Download)
    def _load_ticket(self, stream_slug, destination_uuid):
        stream = Stream.get_by(slug=stream_slug)
        if not destination_uuid:
            return Ticket.get_by(stream=stream, destination=Node.me())
 
            # TODO this block is somewhat duplicated from TicketsHandler.post,
            # where we refresh an existing ticket.
            if not ticket.source == Node.me():
                log.info("Refreshing %s with the source", ticket)
                ticket = TicketsHandler._request_stream_from_node(ticket.stream,
    def run(self):
        if self.ticket.confirmed and not self.ticket.source == Node.me():
            if self.ticket.destination == Node.me():
                if self.request.remote_ip == '127.0.0.1':
                    log.info("User is canceling %s -- must inform sender",

src/a/s/astral-HEAD/astral/models/stream.py   astral(Download)
        so we have something to control.
        """
        if self.source == Node.me():
            TUNNEL_QUEUE.put(self)
 

src/a/s/astral-HEAD/astral/node/tunnel.py   astral(Download)
    def _handle_ticket(self, ticket):
        # reload to get a new database session
        ticket = Ticket.get_by(id=ticket.id)
        if ticket.source == Node.me():
            source_ip = "127.0.0.1"

src/a/s/astral-HEAD/astral/models/tests/test_node.py   astral(Download)
    def setUp(self):
        super(BaseNodeTest, self).setUp()
        self.node = Node.me()
 
 

src/a/s/astral-HEAD/astral/api/tests/test_tickets.py   astral(Download)
    def test_create(self):
        stream = StreamFactory(source=Node.me())
        node = NodeFactory()
        self.http_client.fetch(HTTPRequest(
            self.get_url(stream.tickets_url()), 'POST',
    def test_trigger_locally(self):
        stream = StreamFactory(source=Node.me())
        self.http_client.fetch(HTTPRequest(
            self.get_url(stream.tickets_url()), 'POST', body=''),
            self.stop)
        ticket = Ticket.query.first()
        eq_(ticket.stream, stream)
        eq_(ticket.destination, Node.me())
 
    def test_create_twice_locally(self):
        stream = StreamFactory(source=Node.me())
        TicketFactory(stream=stream, source=Node.me(),

src/a/s/astral-HEAD/astral/api/tests/test_ticket.py   astral(Download)
    def test_delete(self):
        node = Node.me()
        ticket = TicketFactory(destination=node)
        self.http_client.fetch(HTTPRequest(
            self.get_url(ticket.absolute_url()), 'DELETE'), self.stop)
    def test_get(self):
        node = Node.me()
        ticket = TicketFactory(destination=node)
        mockito.when(TicketsAPI).create(mockito.any(),
                destination_uuid=mockito.any()).thenReturn(
    def test_confirm(self):
        node = Node.me()
        ticket = TicketFactory(destination=node, confirmed=False)
        data = {'confirmed': True}
        eq_(ticket.confirmed, False)

src/a/s/astral-HEAD/astral/api/tests/test_streams.py   astral(Download)
    def test_get_streams(self):
        Node.me()
        [StreamFactory() for _ in range(3)]
        response = self.fetch('/streams')
        eq_(response.code, 200)