Ejemplo n.º 1
0
    def __init__(self,
                 environment=None,
                 parent=None,
                 reference_resolution=None):
        super(MainDialog, self).__init__(parent)
        self.setupUi(self)

        # change the window title
        self.setWindowTitle(self.windowTitle())

        # center to the window
        self.center_window()

        self.new_versions = []

        # setup the environment
        self.environment = self._validate_environment(environment)

        if reference_resolution is None:
            # generate from environment
            if self.environment:
                reference_resolution = \
                    self.environment.check_referenced_versions()
            else:
                # create an empty one
                reference_resolution = empty_reference_resolution()
        self.reference_resolution = reference_resolution

        self.setup_signals()

        self._fill_UI()
Ejemplo n.º 2
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """Opens the given version file

        :param version: The Stalker version instance
        :param force: force open, so don't care if there are any unsaved
          changes in the current scene.
        :param representation: The desired representation for the XRef files
          (Not Implemented)
        :param reference_depth: (Not Implemented)
        :param skip_update_check: (Not Implemented)
        :return: Returns a reference resolution that shows what to update.
        """
        # before open: set the system units and gamma settings to their
        # defaults
        self.set_system_units()
        self.set_gamma_settings()

        # set the project dir
        self.set_project(version)

        # then open the file
        MaxPlus.FileManager.Open(version.absolute_full_path, True)

        if not skip_update_check:
            # check the referenced versions for any possible updates
            return self.check_referenced_versions()
        else:
            from anima.env import empty_reference_resolution
            return empty_reference_resolution()
Ejemplo n.º 3
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """the open action for nuke environment
        """
        version_full_path = os.path.normpath(version.absolute_full_path)

        # delete all the comps and open new one
        #comps = self.fusion.GetCompList().values()
        #for comp_ in comps:
        #    comp_.Close()

        self.fusion.LoadComp(version_full_path.encode())

        rfm = RecentFileManager()
        rfm.add(self.name, version.absolute_full_path)

        # set the project_directory
        #self.project_directory = os.path.dirname(version.absolute_path)

        # TODO: file paths in different OS'es should be replaced with the current one
        # Check if the file paths are starting with a string matching one of
        # the OS'es project_directory path and replace them with a relative one
        # matching the current OS

        # replace paths
        #self.replace_external_paths()

        # return True to specify everything was ok and an empty list
        # for the versions those needs to be updated
        return empty_reference_resolution()
Ejemplo n.º 4
0
    def open(self,
             version,
             force=False,
             representation=None,
             reference_depth=0,
             skip_update_check=False):
        """the open action for nuke environment
        """
        nuke.scriptOpen(version.absolute_full_path)

        # set the project_directory
        self.project_directory = os.path.dirname(version.absolute_path)

        # TODO: file paths in different OS's should be replaced with the current one
        # Check if the file paths are starting with a string matching one of the
        # OS's project_directory path and replace them with a relative one
        # matching the current OS

        # replace paths
        self.replace_external_paths()

        # return True to specify everything was ok and an empty list
        # for the versions those needs to be updated
        from anima.env import empty_reference_resolution
        return empty_reference_resolution()
Ejemplo n.º 5
0
    def open(self,
             version,
             force=False,
             representation=None,
             reference_depth=0,
             skip_update_check=False):
        """the open action for houdini environment
        """
        if not version:
            return

        if hou.hipFile.hasUnsavedChanges() and not force:
            raise RuntimeError

        hou.hipFile.load(file_name=str(version.absolute_full_path),
                         suppress_save_prompt=True)

        # set the environment variables
        self.set_environment_variables(version)

        # append it to the recent file list
        self.append_to_recent_files(version.absolute_full_path)

        from anima.env import empty_reference_resolution
        return empty_reference_resolution()
Ejemplo n.º 6
0
    def __init__(self, environment=None, parent=None,
                 reference_resolution=None):
        super(MainDialog, self).__init__(parent)
        self.setupUi(self)

        # change the window title
        self.setWindowTitle(self.windowTitle())

        # center to the window
        self.center_window()

        self.new_versions = []

        # setup the environment
        self.environment = self._validate_environment(environment)

        if reference_resolution is None:
            # generate from environment
            if self.environment:
                reference_resolution = \
                    self.environment.check_referenced_versions()
            else:
                # create an empty one
                reference_resolution = empty_reference_resolution()
        self.reference_resolution = reference_resolution

        self.setup_signals()

        self._fill_UI()
Ejemplo n.º 7
0
    def open(self,
             version,
             force=False,
             representation=None,
             reference_depth=0,
             skip_update_check=False):
        """the open action for nuke environment
        """
        version_full_path = os.path.normpath(version.absolute_full_path)

        # delete all the comps and open new one
        #comps = self.fusion.GetCompList().values()
        #for comp_ in comps:
        #    comp_.Close()

        self.fusion.LoadComp(version_full_path.encode())

        rfm = RecentFileManager()
        rfm.add(self.name, version.absolute_full_path)

        # set the project_directory
        #self.project_directory = os.path.dirname(version.absolute_path)

        # TODO: file paths in different OS'es should be replaced with the current one
        # Check if the file paths are starting with a string matching one of
        # the OS'es project_directory path and replace them with a relative one
        # matching the current OS

        # replace paths
        #self.replace_external_paths()

        # return True to specify everything was ok and an empty list
        # for the versions those needs to be updated
        return empty_reference_resolution()
Ejemplo n.º 8
0
    def open(self,
             version,
             force=False,
             representation=None,
             reference_depth=0,
             skip_update_check=False):
        """Opens the given version file

        :param version: The Stalker version instance
        :param force: force open, so don't care if there are any unsaved
          changes in the current scene.
        :param representation: The desired representation for the XRef files
          (Not Implemented)
        :param reference_depth: (Not Implemented)
        :param skip_update_check: (Not Implemented)
        :return: Returns a reference resolution that shows what to update.
        """
        # before open: set the system units and gamma settings to their
        # defaults
        self.set_system_units()
        self.set_gamma_settings()

        # set the project dir
        self.set_project(version)

        # then open the file
        MaxPlus.FileManager.Open(version.absolute_full_path, True)

        if not skip_update_check:
            # check the referenced versions for any possible updates
            return self.check_referenced_versions()
        else:
            from anima.env import empty_reference_resolution
            return empty_reference_resolution()
Ejemplo n.º 9
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """open action for photoshop environment

        :param version: stalker.models.version.Version instance
        :param force: force open file
        :return:
        """
        version_full_path = version.absolute_full_path
        version_full_path = version_full_path.replace('/', '\\')
        self.photoshop.Load(version_full_path)

        rfm = RecentFileManager()
        rfm.add(self.name, version.absolute_full_path)

        return empty_reference_resolution()
Ejemplo n.º 10
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """open action for photoshop environment

        :param version: stalker.models.version.Version instance
        :param force: force open file
        :return:
        """
        version_full_path = version.absolute_full_path
        version_full_path = version_full_path.replace('/', '\\')
        self.photoshop.Load(version_full_path)

        rfm = RecentFileManager()
        rfm.add(self.name, version.absolute_full_path)

        return empty_reference_resolution()
Ejemplo n.º 11
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """The overridden open method

        :param version:
        :param force:
        :param representation:
        :param reference_depth:
        :param skip_update_check:
        :return:
        """
        self.app.FileOpen(
            str(version.absolute_full_path)
        )

        from anima.env import empty_reference_resolution
        return empty_reference_resolution()
Ejemplo n.º 12
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """The overridden open method

        :param version:
        :param force:
        :param representation:
        :param reference_depth:
        :param skip_update_check:
        :return:
        """
        self.app.FileOpen(
            str(version.absolute_full_path)
        )

        from anima.env import empty_reference_resolution
        return empty_reference_resolution()
Ejemplo n.º 13
0
    def generate_reference_resolution(self):
        """Generates a new reference_resolution dictionary from the UI

        :return: dictionary
        """
        generated_reference_resolution = empty_reference_resolution()

        # append anything that is checked

        version_tree_model = self.versions_treeView.model()
        for i in range(version_tree_model.rowCount()):
            index = version_tree_model.index(i, 0)
            version_item = version_tree_model.itemFromIndex(index)
            if version_item.checkState() == QtCore.Qt.Checked:
                version = version_item.version
                generated_reference_resolution['update'].append(version)

        return generated_reference_resolution
Ejemplo n.º 14
0
    def generate_reference_resolution(self):
        """Generates a new reference_resolution dictionary from the UI

        :return: dictionary
        """
        generated_reference_resolution = empty_reference_resolution()

        # append anything that is checked

        version_tree_model = self.versions_treeView.model()
        for i in range(version_tree_model.rowCount()):
            index = version_tree_model.index(i, 0)
            version_item = version_tree_model.itemFromIndex(index)
            if version_item.checkState() == QtCore.Qt.Checked:
                version = version_item.version
                generated_reference_resolution['update'].append(version)

        return generated_reference_resolution
Ejemplo n.º 15
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """the open action for nuke environment
        """
        nuke.scriptOpen(version.absolute_full_path)

        # set the project_directory
        # self.project_directory = os.path.dirname(version.absolute_path)

        # TODO: file paths in different OS'es should be replaced with the current one
        # Check if the file paths are starting with a string matching one of the
        # OS'es project_directory path and replace them with a relative one
        # matching the current OS

        # replace paths
        # self.replace_external_paths()

        # return True to specify everything was ok and an empty list
        # for the versions those needs to be updated
        return empty_reference_resolution()
Ejemplo n.º 16
0
    def open(self,
             version,
             force=False,
             representation=None,
             reference_depth=0,
             skip_update_check=False):
        """the open action for nuke environment
        """
        version_full_path = os.path.normpath(version.absolute_full_path)

        # # delete all the comps and open new one
        # comps = self.fusion.GetCompList().values()
        # for comp_ in comps:
        #     comp_.Close()

        self.fusion.LoadComp(version_full_path if sys.version_info[0] >= 3 else
                             version_full_path.encode())

        self.comp.Lock()

        # set the project_directory
        # get the current comp fist
        self.comp = self.fusion.GetCurrentComp()
        self.project_directory = os.path.dirname(version.absolute_path)

        # update the savers
        self.create_main_saver_node(version)

        # file paths in different OS'es should be replaced with a path that is suitable for the current one
        # update loaders
        self.fix_loader_paths()

        self.comp.Unlock()

        rfm = RecentFileManager()
        rfm.add(self.name, version.absolute_full_path)

        # return True to specify everything was ok and an empty list
        # for the versions those needs to be updated
        return empty_reference_resolution()
Ejemplo n.º 17
0
    def open(self, version, force=False, representation=None,
             reference_depth=0, skip_update_check=False):
        """the open action for houdini environment
        """
        if not version:
            return

        if hou.hipFile.hasUnsavedChanges() and not force:
            raise RuntimeError

        hou.hipFile.load(
            file_name=str(version.absolute_full_path),
            suppress_save_prompt=True
        )

        # set the environment variables
        self.set_environment_variables(version)

        # append it to the recent file list
        self.append_to_recent_files(
            version.absolute_full_path
        )

        return empty_reference_resolution()
Ejemplo n.º 18
0
    def check_referenced_versions(self):
        """Deeply checks all the references in the scene and returns a
        dictionary which uses the ids of the Versions as key and the action as
        value.

        Uses the top level references to get a Stalker Version instance and
        then tracks all the changes from these Version instances.

        :return: list
        """
        # reverse walk in DFS
        dfs_version_references = []
        version = self.get_current_version()
        resolution_dictionary = empty_reference_resolution(
            root=self.get_referenced_versions()
        )

        # TODO: with Stalker v0.2.5 replace this with Version.walk_inputs()

        for v in version.walk_hierarchy():
            dfs_version_references.append(v)

        # pop the first element which is the current scene
        dfs_version_references.pop(0)

        # iterate back in the list
        for v in reversed(dfs_version_references):
            # check inputs first
            to_be_updated_list = []
            for ref_v in v.inputs:
                if not ref_v.is_latest_published_version():
                    to_be_updated_list.append(ref_v)

            if to_be_updated_list:
                action = 'create'
                # check if there is a new published version of this version
                # that is using all the updated versions of the references
                latest_published_version = v.latest_published_version
                if latest_published_version and \
                   not v.is_latest_published_version():
                    # so there is a new published version
                    # check if its children needs any update
                    # and the updated child versions are already
                    # referenced to the this published version
                    if all([ref_v.latest_published_version
                            in latest_published_version.inputs
                            for ref_v in to_be_updated_list]):
                        # so all new versions are referenced to this published
                        # version, just update to this latest published version
                        action = 'update'
                    else:
                        # not all references are in the inputs
                        # so we need to create a new version as usual
                        # and update the references to the latest versions
                        action = 'create'
            else:
                # nothing needs to be updated,
                # so check if this version has a new version,
                # also there could be no reference under this referenced
                # version
                if v.is_latest_published_version():
                    # do nothing
                    action = 'leave'
                else:
                    # update to latest published version
                    action = 'update'

                # before setting the action check all the inputs in
                # resolution_dictionary, if any of them are update, or create
                # then set this one to 'create'
                if any(rev_v in resolution_dictionary['update'] or
                       rev_v in resolution_dictionary['create']
                       for rev_v in v.inputs):
                    action = 'create'

            # so append this v to the related action list
            resolution_dictionary[action].append(v)

        return resolution_dictionary
Ejemplo n.º 19
0
    def check_referenced_versions(self):
        """Deeply checks all the references in the scene and returns a
        dictionary which uses the ids of the Versions as key and the action as
        value.

        Uses the top level references to get a Stalker Version instance and
        then tracks all the changes from these Version instances.

        :return: list
        """
        # reverse walk in DFS
        dfs_version_references = []
        version = self.get_current_version()
        resolution_dictionary = empty_reference_resolution(
            root=self.get_referenced_versions())

        # TODO: with Stalker v0.2.5 replace this with Version.walk_inputs()

        for v in version.walk_hierarchy():
            dfs_version_references.append(v)

        # pop the first element which is the current scene
        dfs_version_references.pop(0)

        # iterate back in the list
        for v in reversed(dfs_version_references):
            # check inputs first
            to_be_updated_list = []
            for ref_v in v.inputs:
                if not ref_v.is_latest_published_version():
                    to_be_updated_list.append(ref_v)

            if to_be_updated_list:
                action = 'create'
                # check if there is a new published version of this version
                # that is using all the updated versions of the references
                latest_published_version = v.latest_published_version
                if latest_published_version and \
                   not v.is_latest_published_version():
                    # so there is a new published version
                    # check if its children needs any update
                    # and the updated child versions are already
                    # referenced to the this published version
                    if all([
                            ref_v.latest_published_version
                            in latest_published_version.inputs
                            for ref_v in to_be_updated_list
                    ]):
                        # so all new versions are referenced to this published
                        # version, just update to this latest published version
                        action = 'update'
                    else:
                        # not all references are in the inputs
                        # so we need to create a new version as usual
                        # and update the references to the latest versions
                        action = 'create'
            else:
                # nothing needs to be updated,
                # so check if this version has a new version,
                # also there could be no reference under this referenced
                # version
                if v.is_latest_published_version():
                    # do nothing
                    action = 'leave'
                else:
                    # update to latest published version
                    action = 'update'

                # before setting the action check all the inputs in
                # resolution_dictionary, if any of them are update, or create
                # then set this one to 'create'
                if any(rev_v in resolution_dictionary['update']
                       or rev_v in resolution_dictionary['create']
                       for rev_v in v.inputs):
                    action = 'create'

            # so append this v to the related action list
            resolution_dictionary[action].append(v)

        return resolution_dictionary
Ejemplo n.º 20
0
    def check_referenced_versions(self, pdm=None):
        """Deeply checks all the references in the scene and returns a
        dictionary which has three keys called 'leave', 'update' and 'create'.

        Each of these keys correspond to a value of a list of
        :class:`~stalker.model.version.Version`\ s. Where the list in 'leave'
        key shows the Versions referenced (or deeply referenced) to the
        current scene which doesn't need to be changed.

        The list in 'update' key holds Versions those need to be updated to a
        newer version which are already exist.

        The list in 'create' key holds Version instance which needs to have its
        references to be updated to the never versions thus need a new version
        for them self.

        All the Versions in the list are sorted from the deepest to shallowest
        reference, so processing the list from 0th element to nth will always
        guarantee up to date info for the currently processed Version instance.

        Uses the top level references to get a Stalker Version instance and
        then tracks all the changes from these Version instances.

        :return: dictionary
        """
        if not pdm:
            from anima.ui.progress_dialog import ProgressDialogManager
            pdm = ProgressDialogManager()

        caller = \
            pdm.register(
                3,
                '%s.check_referenced_versions() prepare data' %
                self.__class__.__name__
            )

        # deeply get which file is referencing which other files
        self.deep_version_inputs_update()
        if caller:
            caller.step()

        from anima.env import empty_reference_resolution
        reference_resolution = \
            empty_reference_resolution(root=self.get_referenced_versions())

        if caller:
            caller.step()

        # reverse walk in DFS
        dfs_version_references = []

        version = self.get_current_version()
        if not version:
            return reference_resolution

        for v in version.walk_inputs():
            dfs_version_references.append(v)

        if caller:
            caller.step()

        # pop the first element which is the current scene
        dfs_version_references.pop(0)

        caller.end_progress()

        # register a new caller
        caller = pdm.register(
            len(dfs_version_references),
            '%s.check_referenced_versions()' % self.__class__.__name__
        )

        # iterate back in the list
        for v in reversed(dfs_version_references):
            # check inputs first
            to_be_updated_list = []
            for ref_v in v.inputs:
                if not ref_v.is_latest_published_version():
                    to_be_updated_list.append(ref_v)

            if to_be_updated_list:
                action = 'create'
                # check if there is a new published version of this version
                # that is using all the updated versions of the references
                latest_published_version = v.latest_published_version
                if latest_published_version and \
                        not v.is_latest_published_version():
                    # so there is a new published version
                    # check if its children needs any update
                    # and the updated child versions are already
                    # referenced to the this published version
                    if all([ref_v.latest_published_version
                            in latest_published_version.inputs
                            for ref_v in to_be_updated_list]):
                        # so all new versions are referenced to this published
                        # version, just update to this latest published version
                        action = 'update'
                    else:
                        # not all references are in the inputs
                        # so we need to create a new version as usual
                        # and update the references to the latest versions
                        action = 'create'
            else:
                # nothing needs to be updated,
                # so check if this version has a new version,
                # also there could be no reference under this referenced
                # version
                if v.is_latest_published_version():
                    # do nothing
                    action = 'leave'
                else:
                    # update to latest published version
                    action = 'update'

                # before setting the action check all the inputs in
                # resolution_dictionary, if any of them are update, or create
                # then set this one to 'create'
                if any(rev_v in reference_resolution['update'] or
                       rev_v in reference_resolution['create']
                       for rev_v in v.inputs):
                    action = 'create'

            # so append this v to the related action list
            reference_resolution[action].append(v)

            # from stalker import Version
            # assert isinstance(v, Version)
            caller.step(message=v.nice_name)

        caller.end_progress()

        return reference_resolution
Ejemplo n.º 21
0
    def check_referenced_versions(self, pdm=None):
        """Deeply checks all the references in the scene and returns a
        dictionary which has three keys called 'leave', 'update' and 'create'.

        Each of these keys correspond to a value of a list of
        :class:`~stalker.model.version.Version`\ s. Where the list in 'leave'
        key shows the Versions referenced (or deeply referenced) to the
        current scene which doesn't need to be changed.

        The list in 'update' key holds Versions those need to be updated to a
        newer version which are already exist.

        The list in 'create' key holds Version instance which needs to have its
        references to be updated to the never versions thus need a new version
        for them self.

        All the Versions in the list are sorted from the deepest to shallowest
        reference, so processing the list from 0th element to nth will always
        guarantee up to date info for the currently processed Version instance.

        Uses the top level references to get a Stalker Version instance and
        then tracks all the changes from these Version instances.

        :return: dictionary
        """
        if not pdm:
            from anima.ui.progress_dialog import ProgressDialogManager
            pdm = ProgressDialogManager()

        caller = \
            pdm.register(
                3,
                '%s.check_referenced_versions() prepare data' %
                self.__class__.__name__
            )

        # deeply get which file is referencing which other files
        self.deep_version_inputs_update()
        if caller:
            caller.step()

        from anima.env import empty_reference_resolution
        reference_resolution = \
            empty_reference_resolution(root=self.get_referenced_versions())

        if caller:
            caller.step()

        # reverse walk in DFS
        dfs_version_references = []

        version = self.get_current_version()
        if not version:
            return reference_resolution

        for v in version.walk_inputs():
            dfs_version_references.append(v)

        if caller:
            caller.step()

        # pop the first element which is the current scene
        dfs_version_references.pop(0)

        caller.end_progress()

        # register a new caller
        caller = pdm.register(
            len(dfs_version_references),
            '%s.check_referenced_versions()' % self.__class__.__name__
        )

        # iterate back in the list
        for v in reversed(dfs_version_references):
            # check inputs first
            to_be_updated_list = []
            for ref_v in v.inputs:
                if not ref_v.is_latest_published_version():
                    to_be_updated_list.append(ref_v)

            if to_be_updated_list:
                action = 'create'
                # check if there is a new published version of this version
                # that is using all the updated versions of the references
                latest_published_version = v.latest_published_version
                if latest_published_version and \
                        not v.is_latest_published_version():
                    # so there is a new published version
                    # check if its children needs any update
                    # and the updated child versions are already
                    # referenced to the this published version
                    if all([ref_v.latest_published_version
                            in latest_published_version.inputs
                            for ref_v in to_be_updated_list]):
                        # so all new versions are referenced to this published
                        # version, just update to this latest published version
                        action = 'update'
                    else:
                        # not all references are in the inputs
                        # so we need to create a new version as usual
                        # and update the references to the latest versions
                        action = 'create'
            else:
                # nothing needs to be updated,
                # so check if this version has a new version,
                # also there could be no reference under this referenced
                # version
                if v.is_latest_published_version():
                    # do nothing
                    action = 'leave'
                else:
                    # update to latest published version
                    action = 'update'

                # before setting the action check all the inputs in
                # resolution_dictionary, if any of them are update, or create
                # then set this one to 'create'
                if any(rev_v in reference_resolution['update'] or
                       rev_v in reference_resolution['create']
                       for rev_v in v.inputs):
                    action = 'create'

            # so append this v to the related action list
            reference_resolution[action].append(v)

            # from stalker import Version
            # assert isinstance(v, Version)
            caller.step(message=v.nice_name)

        caller.end_progress()

        return reference_resolution