Esempio n. 1
0
    def get_families(self):

        families = io.distinct("data.families") + io.distinct("data.family")
        unique_families = set(families)

        # Sort and convert to list
        collected = sorted(list(unique_families))

        completer = QtWidgets.QCompleter(collected)
        completer.setCaseSensitivity(False)

        self.family.setCompleter(completer)
        self.family.addItems(collected)
Esempio n. 2
0
    def on_project_changed(self, index):
        name = model.data(index, "name")
        api.Session["AVALON_PROJECT"] = name

        # Establish a connection to the project database
        self.log("Connecting to %s" % name, level=INFO)

        project = io.find_one({"type": "project"})

        assert project is not None, "This is a bug"

        # Get available project actions and the application actions
        actions = api.discover(api.Action)
        apps = lib.get_apps(project)
        self._registered_actions[:] = actions + apps

        silos = io.distinct("silo")
        self._model.push([
            dict({
                "name": silo,
                "icon": DEFAULTS["icon"]["silo"],
            }) for silo in sorted(silos)
        ])

        frame = project
        frame["project"] = project["_id"]
        frame["environment"] = {"project": name}
        frame["environment"].update({
            "project_%s" % key: str(value)
            for key, value in project["data"].items()
        })

        self._frames.append(frame)
        self.pushed.emit(name)
Esempio n. 3
0
    def on_project_changed(self, index):
        name = model.data(index, "name")

        # Establish a connection to the project database
        self.log("Connecting to %s" % name, level=INFO)
        io.activate_project(name)

        frame = self.current_frame()
        project = io.find_one({"type": "project"})

        assert project is not None, "This is a bug"

        frame["config"] = project["config"]

        silos = io.distinct("silo")
        self._model.push([
            dict({
                "name": silo,
                "icon": DEFAULTS["icon"]["silo"],
            }) for silo in silos
        ])

        frame["project"] = project["_id"]
        frame["environment"]["project"] = name
        frame["environment"].update({
            "project_%s" % key: str(value)
            for key, value in project["data"].items()
        })

        self._frames.append(frame)
        self.pushed.emit(name)
Esempio n. 4
0
    def on_project_changed(self, index):
        name = model.data(index, "name")
        api.Session["AVALON_PROJECT"] = name

        # Establish a connection to the project database
        self.log("Connecting to %s" % name, level=INFO)

        frame = self.current_frame()
        project = io.find_one({"type": "project"})

        assert project is not None, "This is a bug"

        frame["config"] = project["config"]

        # Use project root if exists or default root will be used
        # (NOTE): The root path from `self._root` may have path sep appended
        #         because it's been processed by `os.path.realpath` in
        #         `app.main`
        root = project["data"].get("root", self._root)
        os.environ["AVALON_PROJECTS"] = root
        api.Session["AVALON_PROJECTS"] = root

        # Get available project actions and the application actions
        actions = api.discover(api.Action)
        apps = lib.get_apps(project)
        self._registered_actions[:] = actions + apps

        silos = io.distinct("silo")
        self._model.push([
            dict({
                "name": silo,
                "icon": DEFAULTS["icon"]["silo"],
            })
            for silo in sorted(silos)
            if self._get_silo_visible(silo)
        ])

        frame["project"] = project["_id"]
        frame["environment"]["project"] = name
        frame["environment"].update({
            "project_%s" % key: str(value)
            for key, value in project["data"].items()
        })

        self._frames.append(frame)
        self.pushed.emit(name)
Esempio n. 5
0
    def on_start(self):
        project_name = io.Session['AVALON_PROJECT']
        project_query = 'Project where full_name is "{}"'.format(project_name)
        if self.session is None:
            session = ftrack_api.Session()
            self.session = session
        else:
            session = self.session
        ft_project = session.query(project_query).one()
        schema_name = ft_project['project_schema']['name']
        # Load config
        schemas_items = get_current_project_settings().get('ftrack', {}).get(
            'project_schemas', {}
        )
        # Get info if it is silo project
        self.silos = io.distinct("silo")
        if self.silos and None in self.silos:
            self.silos = None

        key = "default"
        if schema_name in schemas_items:
            key = schema_name

        self.config_data = schemas_items[key]

        # set outlink
        input_outlink = self.data['inputs']['outlink']
        checkbox_outlink = self.data['inputs']['outlink_cb']
        outlink_text = io.Session.get('AVALON_ASSET', '')
        checkbox_outlink.setChecked(True)
        if outlink_text == '':
            outlink_text = '< No context >'
            checkbox_outlink.setChecked(False)
            checkbox_outlink.hide()
        input_outlink.setText(outlink_text)

        # load asset build types
        self.load_assetbuild_types()

        # Load task templates
        self.load_task_templates()
        self.data["model"]["assets"].refresh()
        self.on_asset_changed()
Esempio n. 6
0
def find_paths_by_hash(texture_hash):
    # Find the texture hash key in the dictionary and all paths that
    # originate from it.
    key = "data.sourceHashes.{0}".format(texture_hash)
    return io.distinct(key, {"type": "version"})
Esempio n. 7
0
 def list_silos(self, *args):
     for silo in io.distinct("silo"):
         yield {"name": silo, "_id": silo}