@classmethod
    def move_cache_files(cls, source_driver, target_driver):
        """moves the selected cache files to another location

        :param source_driver:
        :param target_driver:
        :return:
        """
        #
        # Move fur caches to new server
        #
        import os
        import shutil
        import glob

        from maya import OpenMayaUI
        from shiboken import wrapInstance

        from anima.ui import progress_dialog

        maya_main_window = wrapInstance(
            long(OpenMayaUI.MQtUtil.mainWindow()),
            progress_dialog.QtGui.QWidget
        )

        pdm = ProgressDialogManager(parent=maya_main_window)

        selected_nodes = pm.ls(sl=1)
        caller = pdm.register(len(selected_nodes), title='Moving Cache Files')

        for node in selected_nodes:
            ass_node = node.getShape()

            if not isinstance(ass_node, (pm.nt.AiStandIn, pm.nt.AiVolume)):
                continue

            if isinstance(ass_node, pm.nt.AiStandIn):
                ass_path = ass_node.dso.get()
            elif isinstance(ass_node, pm.nt.AiVolume):
                ass_path = ass_node.filename.get()

            ass_path = os.path.normpath(
                os.path.expandvars(ass_path)
            )

            # give info to user
            caller.title = 'Moving: %s' % ass_path

            # check if it is in the source location
            if source_driver not in ass_path:
                continue

            # check if it contains .ass.gz in its path
            if isinstance(ass_node, pm.nt.AiStandIn):
                if '.ass.gz' not in ass_path:
                    continue
            elif isinstance(ass_node, pm.nt.AiVolume):
                if '.vdb' not in ass_path:
                    continue

            # get the dirname
            ass_source_dir = os.path.dirname(ass_path)
            ass_target_dir = ass_source_dir.replace(source_driver, target_driver)

            # create the intermediate folders at destination
            try:
                os.makedirs(
                    ass_target_dir
                )
            except __HOLE__:
                # dir already exists
                pass

            # get all files list
            pattern = re.subn(r'[#]+', '*', ass_path)[0].replace('.ass.gz', '.ass*')
            all_cache_files = glob.glob(pattern)

            inner_caller = pdm.register(len(all_cache_files))
            for source_f in all_cache_files:
                target_f = source_f.replace(source_driver, target_driver)
                # move files to new location
                shutil.move(source_f, target_f)
                inner_caller.step(message='Moving: %s' % source_f)
            inner_caller.end_progress()

            # finally update DSO path
            if isinstance(ass_node, pm.nt.AiStandIn):
                ass_node.dso.set(ass_path.replace(source_driver, target_driver))
            elif isinstance(ass_node, pm.nt.AiVolume):
                ass_node.filename.set(
                    ass_path.replace(source_driver, target_driver)
                )

            caller.step()
        caller.end_progress()
dataset/ETHPy150Open eoyilmaz/anima/anima/env/mayaEnv/toolbox.py/Render.move_cache_files