Пример #1
0
    def _on_selection_changed(self, selected, deselected):
        """ Get the path to the config for the project that was just selected. """
        # turn on wait cursor
        QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)

        try:
            self._project_config_path = None
            indexes = selected.indexes()

            if indexes:
                # get the primary config path from Shotgun for the selected project
                project_id = indexes[0].data(ProjectModel.PROJECT_ID_ROLE)
                sg = shotgun.create_sg_connection()

                filters = [
                    ["code", "is", constants.PRIMARY_PIPELINE_CONFIG_NAME],
                    ["project", "is", {
                        "type": "Project",
                        "id": project_id
                    }],
                ]
                fields = ["code", "mac_path", "windows_path", "linux_path"]
                configuration = sg.find_one(
                    constants.PIPELINE_CONFIGURATION_ENTITY,
                    filters,
                    fields=fields)

                if configuration is not None:
                    if sys.platform == "win32":
                        self._project_config_path = configuration.get(
                            "windows_path")
                    elif sys.platform == "darwin":
                        self._project_config_path = configuration.get(
                            "mac_path")
                    elif sys.platform.startswith("linux"):
                        self._project_config_path = configuration.get(
                            "linux_path")

                wiz = self.wizard()
                if not self._project_config_path:
                    project_name = indexes[0].data(
                        ProjectModel.DISPLAY_NAME_ROLE)
                    wiz.ui.project_errors.setText(
                        "Could not find configuration for '%s'" % project_name)
                else:
                    wiz.ui.project_errors.setText("")
        finally:
            # restore the regular cursor
            QtGui.QApplication.restoreOverrideCursor()

        # signal the wizard that the Next button's state may have changed
        self.completeChanged.emit()
    def _on_selection_changed(self, selected, deselected):
        """ Get the path to the config for the project that was just selected. """
        # turn on wait cursor
        QtGui.QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)

        try:
            self._project_config_path = None
            indexes = selected.indexes()

            if indexes:
                # get the primary config path from Shotgun for the selected project
                project_id = indexes[0].data(ProjectModel.PROJECT_ID_ROLE)
                sg = shotgun.create_sg_connection()

                filters = [
                    ["code", "is", constants.PRIMARY_PIPELINE_CONFIG_NAME],
                    ["project", "is", {"type": "Project", "id": project_id}],
                ]
                fields = ["code", "mac_path", "windows_path", "linux_path"]
                configuration = sg.find_one(
                    constants.PIPELINE_CONFIGURATION_ENTITY, filters, fields=fields)

                if configuration is not None:
                    if sys.platform == "win32":
                        self._project_config_path = configuration.get("windows_path")
                    elif sys.platform == "darwin":
                        self._project_config_path = configuration.get("mac_path")
                    elif sys.platform.startswith("linux"):
                        self._project_config_path = configuration.get("linux_path")

                wiz = self.wizard()
                if not self._project_config_path:
                    project_name = indexes[0].data(ProjectModel.DISPLAY_NAME_ROLE)
                    wiz.ui.project_errors.setText("Could not find configuration for '%s'" % project_name)
                else:
                    wiz.ui.project_errors.setText("")
        finally:
            # restore the regular cursor
            QtGui.QApplication.restoreOverrideCursor()

        # signal the wizard that the Next button's state may have changed
        self.completeChanged.emit()
            except Exception, e:
                # could not create all the directories, report and bail
                message = "Got the following errors creating the directory:\n%s" % str(e)
                QtGui.QMessageBox.critical(self, "Error creating directories.", message)
                return False
            finally:
                os.umask(old_umask)

        # report if invalid paths were entered
        if invalid:
            error = "All paths must be filled out with absolute paths."
            self.storage_errors.setText(error)
            return False

        # do create
        sg = shotgun.create_sg_connection()
        if create_in_shotgun:
            try:
                shotgun_store = sg.create("LocalStorage", create_in_shotgun)
                self._store_info["defined_in_shotgun"] = True
                self._store_info["shotgun_id"] = shotgun_store["id"]
                self._store_info["darwin"] = mac_path
                self._store_info["linux2"] = linux_path
                self._store_info["win32"] = windows_path
            except Exception, e:
                self.storage_errors.setText("Error creating Storage in Shotgun:\n%s" % str(e))
                return False

        # grab the ids for the local storages from Shotgun
        # NOTE: this is temporary until the store_info dictionary includes the id
        if update_in_shotgun:
Пример #4
0
def _shotgun():
    sg = shotgun.create_sg_connection()
    return sg