예제 #1
0
    def get(self):

        if not os.environ["SERVER_SOFTWARE"].startswith('Development'):
            return

        # Delete all bridges and filters so that we have a fresh testing environment
        for bridge in GandalfBridge.all():
            bridge.delete()

        for filter in GandalfFilter.all():
            filter.delete()

        step = self.request.get("step")
        v = None

        if step == "creating_bridge":
            v = self.creating_bridge()
        elif step == "can_cross_empty_bridge":
            v = self.can_cross_empty_bridge()
        elif step == "can_cross_all_users_whitelist":
            v = self.can_cross_all_users_whitelist()
        elif step == "can_cross_all_users_blacklist":
            v = self.can_cross_all_users_blacklist()
        elif step == "can_cross_all_users_whitelist_and_blacklist":
            v = self.can_cross_all_users_whitelist_and_blacklist()
        elif step == "can_cross_all_users_inside_percentage":
            v = self.can_cross_all_users_inside_percentage()
        elif step == "can_cross_all_users_outside_percentage":
            v = self.can_cross_all_users_outside_percentage()

        self.response.out.write(json.dumps(v))
예제 #2
0
파일: __init__.py 프로젝트: di445/server
    def get(self):

        if not os.environ["SERVER_SOFTWARE"].startswith('Development'):
            return

        # Delete all bridges and filters so that we have a fresh testing environment
        for bridge in GandalfBridge.all():
            bridge.delete()
    
        for filter in GandalfFilter.all():
            filter.delete()

        step = self.request.get("step")
        v = None

        if step == "creating_bridge":
            v = self.creating_bridge()
        elif step == "can_cross_empty_bridge":
            v = self.can_cross_empty_bridge()
        elif step == "can_cross_all_users_whitelist":
            v = self.can_cross_all_users_whitelist()
        elif step == "can_cross_all_users_blacklist":
            v = self.can_cross_all_users_blacklist()
        elif step == "can_cross_all_users_whitelist_and_blacklist":
            v = self.can_cross_all_users_whitelist_and_blacklist()
        elif step == "can_cross_all_users_inside_percentage":
            v = self.can_cross_all_users_inside_percentage()
        elif step == "can_cross_all_users_outside_percentage":
            v = self.can_cross_all_users_outside_percentage()

        self.response.out.write(json.dumps(v))
예제 #3
0
    def get(self):

        if not can_control_gandalf():
            return

        bridges = GandalfBridge.all().fetch(900)

        context = {
            "bridges": bridges,
        }

        self.response.headers["Content-Type"] = "application/json"
        self.response.out.write(jsonify(context))
예제 #4
0
파일: api.py 프로젝트: di445/server
    def get(self):

        if not can_control_gandalf():
            return

        bridges = GandalfBridge.all().fetch(900)

        context = {
            "bridges": bridges,
        }

        self.response.headers["Content-Type"] = "application/json"
        self.response.out.write(jsonify(context))
예제 #5
0
    def load_from_datastore():
        gandalf_cache = GandalfCache()

        bridges = GandalfBridge.all()

        for bridge in bridges:

            key = bridge.key().name()

            gandalf_cache.bridges[key] = db.model_to_protobuf(bridge).Encode()

            filters = bridge.gandalffilter_set

            gandalf_cache.filters[key] = []

            for filter in filters:
                gandalf_cache.filters[key].append(db.model_to_protobuf(filter).Encode())

        memcache.set(GandalfCache.MEMCACHE_KEY, gandalf_cache)

        return gandalf_cache
예제 #6
0
    def load_from_datastore():
        gandalf_cache = GandalfCache()

        bridges = GandalfBridge.all()

        for bridge in bridges:

            key = bridge.key().name()

            gandalf_cache.bridges[key] = db.model_to_protobuf(bridge).Encode()

            filters = bridge.gandalffilter_set

            gandalf_cache.filters[key] = []

            for filter in filters:
                gandalf_cache.filters[key].append(db.model_to_protobuf(filter).Encode())

        memcache.set(GandalfCache.MEMCACHE_KEY, gandalf_cache)

        return gandalf_cache