Exemplo n.º 1
0
 def test_add_method_also_calls_save(self):
     """testing if the add method also calls save method
     """
     rfm1 = RecentFileManager()
     rfm1.add('New Env', 'some path')
     rfm2 = RecentFileManager()
     self.assertEqual(rfm2['New Env'], ['some path'])
Exemplo n.º 2
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()
Exemplo 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()
Exemplo n.º 4
0
    def test_restore_limits_maximum_files_stored(self):
        """testing if restore limits the maximum files stored
        """
        rm = RecentFileManager()
        for i in range(anima.max_recent_files + 100):
            rm.add('Env1', 'some path %s' % i)

        rm2 = RecentFileManager()
        self.assertEqual(len(rm2['Env1']), anima.max_recent_files)
Exemplo n.º 5
0
 def test_recent_files_attribute_is_working_properly(self):
     """testing if the recent_files attribute is working properly
     """
     rfm1 = RecentFileManager()
     rfm1.add('New Env', 'some path')
     self.assertEqual(
         rfm1.recent_files,
         {'New Env': ['some path']}
     )
Exemplo n.º 6
0
 def test_add_method_with_a_new_environment_name(self):
     """testing if the add method is able to add files to a new environment
     """
     rfm = RecentFileManager()
     rfm.add('New Env', 'some path')
     self.assertEqual(
         rfm.recent_files['New Env'][0],
         'some path'
     )
Exemplo n.º 7
0
 def test_add_method_also_calls_save(self):
     """testing if the add method also calls save method
     """
     rfm1 = RecentFileManager()
     rfm1.add('New Env', 'some path')
     rfm2 = RecentFileManager()
     self.assertEqual(
         rfm2['New Env'],
         ['some path']
     )
Exemplo n.º 8
0
    def test_restore_limits_maximum_files_stored(self):
        """testing if restore limits the maximum files stored
        """
        rm = RecentFileManager()
        for i in range(anima.max_recent_files + 100):
            rm.add('Env1', 'some path %s' % i)

        rm2 = RecentFileManager()
        self.assertEqual(
            len(rm2['Env1']),
            anima.max_recent_files
        )
Exemplo n.º 9
0
    def test_restore_is_working_properly(self):
        """testing if the restore method is working properly
        """
        rfm1 = RecentFileManager()
        rfm1.add('New Env', 'some path')
        rfm1.save()

        rfm2 = RecentFileManager()
        # clear the recent files
        rfm2.recent_files = []
        rfm2.restore()

        self.assertEqual(rfm2.recent_files['New Env'][0], 'some path')
Exemplo n.º 10
0
    def test_add_method_is_working_properly(self):
        """testing if the add method will add a new file entry to the recent
        files list
        """
        rfm = RecentFileManager()
        test_values = [('Photoshop', 'some path'), ('Maya', 'some other path'),
                       ('Maya', 'some new other path'),
                       ('Photoshop', 'some path 2')]

        for test_value in test_values:
            env_name = test_value[0]
            path = test_value[1]
            rfm.add(env_name, path)

            self.assertEqual(rfm.recent_files[env_name][0], path)
Exemplo n.º 11
0
    def save_as(self, version, run_pre_publishers=True):
        """"the save action for fusion environment

        uses Fusions own python binding
        """
        # set the extension to '.comp'
        # refresh the current comp
        self.comp = self.fusion.GetCurrentComp()
        from stalker import Version
        assert isinstance(version, Version)
        # its a new version please update the paths
        version.update_paths()
        version.extension = self.extensions[0]
        version.created_with = self.name

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

        # create the main write node
        self.create_main_saver_node(version)

        # set range from the shot
        self.set_range_from_shot(version)

        # replace read and write node paths
        # self.replace_external_paths()

        # create the path before saving
        try:
            os.makedirs(version.absolute_path)
        except OSError:
            # path already exists OSError
            pass

        version_full_path = os.path.normpath(version.absolute_full_path)

        self.comp.Lock()
        self.comp.Save(version_full_path if sys.version_info[0] >= 3 else
                       version_full_path.encode())
        self.comp.Unlock()

        # create a local copy
        self.create_local_copy(version)

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

        return True
Exemplo n.º 12
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()
Exemplo n.º 13
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()
Exemplo n.º 14
0
    def test_restore_is_working_properly(self):
        """testing if the restore method is working properly
        """
        rfm1 = RecentFileManager()
        rfm1.add('New Env', 'some path')
        rfm1.save()

        rfm2 = RecentFileManager()
        # clear the recent files
        rfm2.recent_files = []
        rfm2.restore()

        self.assertEqual(
            rfm2.recent_files['New Env'][0],
            'some path'
        )
Exemplo n.º 15
0
    def save_as(self, version):
        """"the save action for fusion environment

        uses Fusions own python binding
        """
        # set the extension to '.comp'
        from stalker import Version
        assert isinstance(version, Version)
        # its a new version please update the paths
        version.update_paths()
        version.extension = '.comp'
        version.created_with = self.name

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

        # create the main write node
        self.create_main_saver_node(version)

        # replace read and write node paths
        #self.replace_external_paths()

        # create the path before saving
        try:
            os.makedirs(version.absolute_path)
        except OSError:
            # path already exists OSError
            pass

        version_full_path = os.path.normpath(version.absolute_full_path)

        self.comp.Lock()
        self.comp.Save(version_full_path.encode())
        self.comp.Unlock()

        # create a local copy
        self.create_local_copy(version)

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

        return True
Exemplo n.º 16
0
    def test_add_method_is_working_properly(self):
        """testing if the add method will add a new file entry to the recent
        files list
        """
        rfm = RecentFileManager()
        test_values = [
            ('Photoshop', 'some path'),
            ('Maya', 'some other path'),
            ('Maya', 'some new other path'),
            ('Photoshop', 'some path 2')
        ]

        for test_value in test_values:
            env_name = test_value[0]
            path = test_value[1]
            rfm.add(env_name, path)

            self.assertEqual(
                rfm.recent_files[env_name][0],
                path
            )
Exemplo n.º 17
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()
Exemplo n.º 18
0
    def test_RecentFileManager_is_indexable(self):
        """testing if the RecentFileManager instance is indexable with the
        environment name
        """
        rfm1 = RecentFileManager()
        rfm1.add('Env1', 'Path1')
        rfm1.add('Env1', 'Path2')
        rfm1.add('Env1', 'Path3')

        rfm1.add('Env2', 'Path4')
        rfm1.add('Env2', 'Path5')
        rfm1.add('Env2', 'Path6')

        self.assertEqual(rfm1['Env1'], ['Path3', 'Path2', 'Path1'])
        self.assertEqual(rfm1['Env2'], ['Path6', 'Path5', 'Path4'])
Exemplo n.º 19
0
    def test_add_method_pops_previous_versions_and_inserts_them_to_0(self):
        """testing if an entry will be popped from the recent_files list if it
        is added to the list again
        """
        rfm1 = RecentFileManager()
        rfm1.add('Env1', 'path1')
        rfm1.add('Env1', 'path2')
        rfm1.add('Env1', 'path3')

        self.assertEqual(rfm1['Env1'], ['path3', 'path2', 'path1'])

        rfm1.add('Env1', 'path1')
        self.assertEqual(rfm1['Env1'], ['path1', 'path3', 'path2'])
Exemplo n.º 20
0
    def test_RecentFileManager_is_indexable(self):
        """testing if the RecentFileManager instance is indexable with the
        environment name
        """
        rfm1 = RecentFileManager()
        rfm1.add('Env1', 'Path1')
        rfm1.add('Env1', 'Path2')
        rfm1.add('Env1', 'Path3')

        rfm1.add('Env2', 'Path4')
        rfm1.add('Env2', 'Path5')
        rfm1.add('Env2', 'Path6')

        self.assertEqual(
            rfm1['Env1'],
            ['Path3', 'Path2', 'Path1']
        )
        self.assertEqual(
            rfm1['Env2'],
            ['Path6', 'Path5', 'Path4']
        )
Exemplo n.º 21
0
    def test_remove_method_removes_files_from_given_env(self):
        """testing if the given path will be removed from the given environment
        """
        rfm1 = RecentFileManager()
        rfm1.add('Env1', 'Path1')
        rfm1.add('Env1', 'Path2')
        rfm1.add('Env1', 'Path3')

        rfm1.add('Env2', 'Path4')
        rfm1.add('Env2', 'Path5')
        rfm1.add('Env2', 'Path6')

        self.assertEqual(
            rfm1['Env1'],
            ['Path3', 'Path2', 'Path1']
        )
        self.assertEqual(
            rfm1['Env2'],
            ['Path6', 'Path5', 'Path4']
        )

        rfm1.remove('Env1', 'Path1')
        self.assertEqual(
            rfm1['Env1'],
            ['Path3', 'Path2']
        )

        rfm1.remove('Env1', 'Path3')
        self.assertEqual(
            rfm1['Env1'],
            ['Path2']
        )

        rfm1.remove('Env2', 'Path5')
        self.assertEqual(
            rfm1['Env2'],
            ['Path6', 'Path4']
        )
Exemplo n.º 22
0
    def test_remove_method_removes_files_from_given_env(self):
        """testing if the given path will be removed from the given environment
        """
        rfm1 = RecentFileManager()
        rfm1.add('Env1', 'Path1')
        rfm1.add('Env1', 'Path2')
        rfm1.add('Env1', 'Path3')

        rfm1.add('Env2', 'Path4')
        rfm1.add('Env2', 'Path5')
        rfm1.add('Env2', 'Path6')

        self.assertEqual(rfm1['Env1'], ['Path3', 'Path2', 'Path1'])
        self.assertEqual(rfm1['Env2'], ['Path6', 'Path5', 'Path4'])

        rfm1.remove('Env1', 'Path1')
        self.assertEqual(rfm1['Env1'], ['Path3', 'Path2'])

        rfm1.remove('Env1', 'Path3')
        self.assertEqual(rfm1['Env1'], ['Path2'])

        rfm1.remove('Env2', 'Path5')
        self.assertEqual(rfm1['Env2'], ['Path6', 'Path4'])
Exemplo n.º 23
0
    def test_add_method_pops_previous_versions_and_inserts_them_to_0(self):
        """testing if an entry will be popped from the recent_files list if it
        is added to the list again
        """
        rfm1 = RecentFileManager()
        rfm1.add('Env1', 'path1')
        rfm1.add('Env1', 'path2')
        rfm1.add('Env1', 'path3')

        self.assertEqual(
            rfm1['Env1'],
            ['path3', 'path2', 'path1']
        )

        rfm1.add('Env1', 'path1')
        self.assertEqual(
            rfm1['Env1'],
            ['path1', 'path3', 'path2']
        )
Exemplo n.º 24
0
    def save_as(self, version, run_pre_publishers=True):
        """"the save action for fusion environment

        uses Fusions own python binding
        """
        # set the extension to '.comp'
        # refresh the current comp
        self.comp = self.fusion.GetCurrentComp()
        from stalker import Version
        assert isinstance(version, Version)
        # its a new version please update the paths
        version.update_paths()
        version.extension = self.extensions[0]
        version.created_with = self.name

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

        # create the main write node
        self.create_main_saver_node(version)

        # check if this is a shot related task
        is_shot_related_task = False
        shot = None
        from stalker import Shot
        for task in version.task.parents:
            if isinstance(task, Shot):
                is_shot_related_task = True
                shot = task
                break

        fps = None
        imf = None
        if not is_shot_related_task:
            # use the Project image_format
            fps = version.task.project.fps
            imf = version.task.project.image_format
        else:
            # use the shot image_format
            if shot:
                fps = shot.fps
                imf = shot.image_format

        # set comp resolution and fps
        if imf:
            self.comp.SetPrefs({
                # Image Format
                "Comp.FrameFormat.Width": imf.width,
                "Comp.FrameFormat.Height": imf.height,
                "Comp.FrameFormat.AspectY": imf.pixel_aspect,
                "Comp.FrameFormat.AspectX": imf.pixel_aspect,

                # FPS
                "Comp.FrameFormat.Rate": fps,

                # set project frame format to 16bit
                "Comp.FrameFormat.DepthFull": 2.0,
                "Comp.FrameFormat.DepthLock": True,
            })

        # replace read and write node paths
        # self.replace_external_paths()

        # create the path before saving
        try:
            os.makedirs(version.absolute_path)
        except OSError:
            # path already exists OSError
            pass

        version_full_path = os.path.normpath(version.absolute_full_path)

        self.comp.Lock()
        self.comp.Save(version_full_path.encode())
        self.comp.Unlock()

        # create a local copy
        self.create_local_copy(version)

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

        return True
Exemplo n.º 25
0
 def append_to_recent_files(self, path):
     """appends the given path to the recent files list
     """
     # add the file to the recent file list
     rfm = RecentFileManager()
     rfm.add(self.name, path)
Exemplo n.º 26
0
 def test_recent_files_attribute_is_working_properly(self):
     """testing if the recent_files attribute is working properly
     """
     rfm1 = RecentFileManager()
     rfm1.add('New Env', 'some path')
     self.assertEqual(rfm1.recent_files, {'New Env': ['some path']})
Exemplo n.º 27
0
 def test_add_method_with_a_new_environment_name(self):
     """testing if the add method is able to add files to a new environment
     """
     rfm = RecentFileManager()
     rfm.add('New Env', 'some path')
     self.assertEqual(rfm.recent_files['New Env'][0], 'some path')
Exemplo n.º 28
0
    def save_as(self, version, run_pre_publishers=True):
        """"the save action for fusion environment

        uses Fusions own python binding
        """
        # set the extension to '.comp'
        # refresh the current comp
        self.comp = self.fusion.GetCurrentComp()
        from stalker import Version
        assert isinstance(version, Version)
        # its a new version please update the paths
        version.update_paths()
        version.extension = self.extensions[0]
        version.created_with = self.name

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

        # create the main write node
        self.create_main_saver_node(version)

        # check if this is a shot related task
        is_shot_related_task = False
        shot = None
        from stalker import Shot
        for task in version.task.parents:
            if isinstance(task, Shot):
                is_shot_related_task = True
                shot = task
                break

        fps = None
        imf = None
        if not is_shot_related_task:
            # use the Project image_format
            fps = version.task.project.fps
            imf = version.task.project.image_format
        else:
            # use the shot image_format
            if shot:
                fps = shot.fps
                imf = shot.image_format

        # set comp resolution and fps
        if imf:
            self.comp.SetPrefs({
                # Image Format
                "Comp.FrameFormat.Width": imf.width,
                "Comp.FrameFormat.Height": imf.height,
                "Comp.FrameFormat.AspectY": imf.pixel_aspect,
                "Comp.FrameFormat.AspectX": imf.pixel_aspect,

                # FPS
                "Comp.FrameFormat.Rate": fps,

                # set project frame format to 16bit
                "Comp.FrameFormat.DepthFull": 2.0,
                "Comp.FrameFormat.DepthLock": True,
            })

        # replace read and write node paths
        # self.replace_external_paths()

        # create the path before saving
        try:
            os.makedirs(version.absolute_path)
        except OSError:
            # path already exists OSError
            pass

        version_full_path = os.path.normpath(version.absolute_full_path)

        self.comp.Lock()
        self.comp.Save(version_full_path.encode())
        self.comp.Unlock()

        # create a local copy
        self.create_local_copy(version)

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

        return True
Exemplo n.º 29
0
 def append_to_recent_files(self, path):
     """appends the given path to the recent files list
     """
     # add the file to the recent file list
     rfm = RecentFileManager()
     rfm.add(self.name, path)