コード例 #1
0
    def send_query(self, id):
        if isinstance(id, Contact):
            id = id.id

        queries_queue = None
        try:
            queries_queue = self.get_optimization('QUERIES_QUEUE')
        except OptimizationNotFound:
            pass

        if queries_queue and queries_queue.is_running():
            if queries_queue.enqueue_query(id):
                return Query(id, 'A charm has been sent')
            else:
                return Query(id, 'Unable to send charm: it has been enqueued')
        else:
            if not self.browser.send_charm(id):
                raise QueryError('No enough charms available')
            return Query(id, 'A charm has been sent')
コード例 #2
0
    def send_query(self, id):
        if isinstance(id, Contact):
            id = id.id

        queries_queue = None
        try:
            queries_queue = self.get_optimization('QUERIES_QUEUE')
        except OptimizationNotFound:
            pass

        if queries_queue and queries_queue.is_running():
            if queries_queue.enqueue_query(id):
                return Query(id, 'A profile was visited')
            else:
                return Query(id,
                             'Unable to visit profile: it has been enqueued')
        else:
            with self.browser:
                if not self.browser.visit_profile(id):
                    raise QueryError('Could not visit profile')
                return Query(id, 'Profile was visited')