Пример #1
0
 def get_empty_tile_containers(self, data):
     cdict = {}
     for i in range(data["number"]):
         tile_container_id = create_container("tactic_tile_image", network_mode="bridge", owner=data["user_id"])
         tile_container_address = get_address(tile_container_id, "bridge")
         send_request_to_container(megaplex_address, "register_container", {"container_id": tile_container_id})
         cdict[tile_container_id] = tile_container_address
     return cdict
Пример #2
0
    def main_project(self, data):
        user_id = data["user_id"]
        project_name = data["project_name"]
        user_manage_id = data["user_manage_id"]
        user_obj = load_user(user_id)
        # noinspection PyTypeChecker
        self.show_um_status_message("creating main container", user_manage_id, None)
        main_id = create_container("tactic_main_image", network_mode="bridge", owner=user_id)
        caddress = get_address(main_id, "bridge")
        send_request_to_container(self.megaplex_address, "register_container", {"container_id": main_id})

        global_tile_manager.add_user(user_obj.username)

        list_names = self.get_list_names({"user_id": user_obj.get_id()})["list_names"]
        class_names = self.get_class_names({"user_id": user_obj.get_id()})["class_names"]
        function_names = self.get_function_tags_dict({"user_id": user_obj.get_id()})["function_names"]

        with self.app.test_request_context():
            bf_url = url_for("figure_source", tile_id="tile_id", figure_name="X")[:-1]

        data_dict = {
            "project_name": project_name,
            "project_collection_name": user_obj.project_collection_name,
            "main_id": main_id,
            "user_id": user_obj.get_id(),
            "megaplex_address": self.megaplex_address,
            "main_address": caddress,
            "loaded_user_modules": global_tile_manager.loaded_user_modules,
            "mongo_uri": mongo_uri,
            "list_names": list_names,
            "class_names": class_names,
            "function_names": function_names,
            "user_manage_id": user_manage_id,
            "base_figure_url": bf_url,
            "use_ssl": use_ssl,
        }

        # noinspection PyTypeChecker
        self.show_um_status_message("start initialize project", user_manage_id, None)
        result = send_request_to_container(caddress, "initialize_project_mainwindow", data_dict).json()
        if not result["success"]:
            destroy_container(main_id)
            raise Exception(result["message_string"])

        return None
Пример #3
0
def create_megaplex():
    global megaplex_address, megaplex_id
    megaplex_id = create_container("tactic_megaplex_image")
    megaplex_address = get_address(megaplex_id, "bridge")
Пример #4
0
 def create_tile_container(self, data):
     tile_container_id = create_container("tactic_tile_image", network_mode="bridge", owner=data["user_id"])
     tile_address = get_address(tile_container_id, "bridge")
     send_request_to_container(megaplex_address, "register_container", {"container_id": tile_container_id})
     return {"tile_id": tile_container_id, "tile_address": tile_address}