Пример #1
0
 def test_register_will_create_the_window_if_it_is_not_created_yet(self):
     """testing if the register method will create the progressWindow if it
     is not created yet
     """
     pm = ProgressDialogManager()
     self.assertFalse(pm.in_progress)
     pm.register(5)
     self.assertTrue(pm.in_progress)
Пример #2
0
 def test_register_will_create_the_window_if_it_is_not_created_yet(self):
     """testing if the register method will create the progressWindow if it
     is not created yet
     """
     pm = ProgressDialogManager()
     self.assertFalse(pm.in_progress)
     pm.register(5)
     self.assertTrue(pm.in_progress)
Пример #3
0
    def namespace_deleter(cls):
        """the legendary namespace deleter from Mehmet Erer

        finds and deletes unused namespaces
        """
        all_namespaces = pm.listNamespaces()
        ref_namespaces = [ref.namespace for ref in pm.listReferences()]
        missing_namespaces = []

        from anima.ui.progress_dialog import ProgressDialogManager
        if len(all_namespaces) > 0:
            pdm = ProgressDialogManager()
            pdm.close()

            caller = pdm.register(len(all_namespaces),
                                  'Locating Unused Namespaces...')
            for nsa in all_namespaces:
                i = 0
                for nsr in ref_namespaces:
                    i += 1
                    if nsr == nsa:
                        break
                    if i == len(ref_namespaces):
                        missing_namespaces.append(nsa)
                caller.step()

        if len(missing_namespaces) > 0:
            caller = pdm.register(len(missing_namespaces),
                                  'Deleting Unused Namespaces...')
            for ns in missing_namespaces:
                ns_info = pm.namespaceInfo(ns, lon=1, fn=1, r=1)
                if len(ns_info) > 0:
                    nsc = ns_info[len(ns_info) - 1]
                    nsc_array = nsc.split(':')
                    if len(nsc_array) > 0:
                        for del_nsc in nsc_array:
                            pm.namespace(rm=del_nsc, mnr=1)
                else:
                    pm.namespace(rm=ns, mnr=1)
                print('Deleted -> :' + ns)
                caller.step()
        else:
            pm.warning(
                'There are no first-level unused namespaces in this scene.'
            )

        if len(ref_namespaces) == 0 and len(all_namespaces) > 0:
            for ns in all_namespaces:
                pm.namespace(rm=ns, mnr=1)
                print('Deleted -> : %s' % ns)
            pm.warning(
                'There are no references in this scene. All empty namespaces '
                'are deleted.'
            )
Пример #4
0
def check_uv_border_crossing():
    """checks if any of the uv shells are crossing uv borders
    """
    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    all_meshes = pm.ls(type='mesh')
    mesh_count = len(all_meshes)

    nodes_with_uvs_crossing_borders = []

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    if not pm.general.about(batch=1) and mesh_count:
        pdm.use_ui = True

    caller = pdm.register(mesh_count, 'check_out_of_space_uvs()')

    for node in all_meshes:
        all_uvs = node.getUVs()
        uv_shell_ids = node.getUvShellsIds()

        # prepare an empty dict of lists
        uvs_per_shell = {}
        for shell_id in range(uv_shell_ids[1]):
            uvs_per_shell[shell_id] = [[], []]

        for uv_id in range(len(uv_shell_ids[0])):
            u = all_uvs[0][uv_id]
            v = all_uvs[1][uv_id]
            shell_id = uv_shell_ids[0][uv_id]

            uvs_per_shell[shell_id][0].append(u)
            uvs_per_shell[shell_id][1].append(v)

        # now check all uvs per shell
        for shell_id in range(uv_shell_ids[1]):
            us = sorted(uvs_per_shell[shell_id][0])
            vs = sorted(uvs_per_shell[shell_id][1])

            # check first and last u and v values
            if int(us[0]) != int(us[-1]) or int(vs[0]) != int(vs[-1]):
                # they are not equal it is crossing spaces
                nodes_with_uvs_crossing_borders.append(node)
                break

        caller.step()

    if len(nodes_with_uvs_crossing_borders):
        # get transform nodes
        tra_nodes = map(lambda x: x.getParent(),
                        nodes_with_uvs_crossing_borders)
        pm.select(tra_nodes)
        raise RuntimeError(
            """There are nodes with <b>UV-Shells</b> that are crossing
            <b>UV BORDERS</b>:<br><br>%s""" %
            '<br>'.join(map(lambda x: x.name(), tra_nodes[:MAX_NODE_DISPLAY])))
Пример #5
0
    def convert(self):
        """converts the given input_file to an rstexbin
        """
        processed_files = []

        import subprocess
        from anima.ui.progress_dialog import ProgressDialogManager
        pdm = ProgressDialogManager()
        caller = pdm.register(len(self.files_to_process),
                              title='Converting Textures')
        for file_path in self.files_to_process:
            command = '%s "%s"' % (self.executable, file_path)
            rsmap_full_path = \
                '%s.rstexbin' % os.path.splitext(file_path)[0]

            # os.system(command)
            if os.name == 'nt':
                proc = subprocess.Popen(command,
                                        creationflags=subprocess.SW_HIDE,
                                        shell=True)
            else:
                proc = subprocess.Popen(command, shell=True)
            proc.wait()

            processed_files.append(rsmap_full_path)
            caller.step()
        caller.end_progress()

        return processed_files
Пример #6
0
 def test_register_will_store_the_given_caller(self):
     """testing if ProgressWindow.register() method will store the given
     name as a key in the ProgressWindow.callers dictionary
     """
     pm = ProgressDialogManager()
     caller = pm.register(100)
     self.assertIn(caller, pm.callers)
Пример #7
0
 def test_register_will_store_the_given_caller(self):
     """testing if ProgressWindow.register() method will store the given
     name as a key in the ProgressWindow.callers dictionary
     """
     pm = ProgressDialogManager()
     caller = pm.register(100)
     self.assertIn(caller, pm.callers)
Пример #8
0
def check_uvs():
    """checks uvs with no uv area

    The area of a 2d polygon calculation is based on the answer of Darius Bacon
    in http://stackoverflow.com/questions/451426/how-do-i-calculate-the-surface-area-of-a-2d-polygon
    """

    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    def area(p):
        return 0.5 * abs(sum(x0 * y1 - x1 * y0
                             for ((x0, y0), (x1, y1)) in segments(p)))

    def segments(p):
        return zip(p, p[1:] + [p[0]])

    all_meshes = pm.ls(type='mesh')
    mesh_count = len(all_meshes)

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    if not pm.general.about(batch=1) and mesh_count:
        pdm.use_ui = True

    caller = pdm.register(mesh_count, 'check_uvs()')

    meshes_with_zero_uv_area = []
    for node in all_meshes:
        all_uvs = node.getUVs()
        try:
            for i in range(node.numFaces()):
                uvs = []
                for j in range(node.numPolygonVertices(i)):
                    # uvs.append(node.getPolygonUV(i, j))
                    uv_id = node.getPolygonUVid(i, j)
                    uvs.append((all_uvs[0][uv_id], all_uvs[1][uv_id]))
                if area(uvs) == 0.0:
                    meshes_with_zero_uv_area.append(node)
                    break
        except RuntimeError:
            meshes_with_zero_uv_area.append(node)

        caller.step()

    if len(meshes_with_zero_uv_area):
        pm.select([node.getParent() for node in meshes_with_zero_uv_area])
        raise RuntimeError(
            """There are meshes with no uvs or faces with zero uv area:<br><br>
            %s""" %
            '<br>'.join(
                map(lambda x: x.name(),
                    meshes_with_zero_uv_area[:MAX_NODE_DISPLAY])
            )
        )
Пример #9
0
    def select_zero_uv_area_faces(cls):
        """selects faces with zero UV area
        """
        def area(p):
            return 0.5 * abs(sum(x0 * y1 - x1 * y0
                                 for ((x0, y0), (x1, y1)) in segments(p)))

        def segments(p):
            return zip(p, p[1:] + [p[0]])

        all_meshes = pm.ls(
            [node.getShape() for node in pm.ls(sl=1)],
            type='mesh'
        )

        mesh_count = len(all_meshes)

        from anima.env.mayaEnv import MayaMainProgressBarWrapper
        from anima.ui.progress_dialog import ProgressDialogManager
        wrp = MayaMainProgressBarWrapper()
        pdm = ProgressDialogManager(dialog=wrp)

        if not pm.general.about(batch=1) and mesh_count:
            pdm.use_ui = True

        caller = pdm.register(mesh_count, 'check_uvs()')

        faces_with_zero_uv_area = []
        for node in all_meshes:
            all_uvs = node.getUVs()
            for i in range(node.numFaces()):
                uvs = []
                try:
                    for j in range(node.numPolygonVertices(i)):
                        # uvs.append(node.getPolygonUV(i, j))
                        uv_id = node.getPolygonUVid(i, j)
                        uvs.append((all_uvs[0][uv_id], all_uvs[1][uv_id]))
                    if area(uvs) == 0.0:
                        # meshes_with_zero_uv_area.append(node)
                        # break
                        faces_with_zero_uv_area.append(
                            '%s.f[%s]' % (node.fullPath(), i)
                        )
                except RuntimeError:
                    faces_with_zero_uv_area.append(
                        '%s.f[%s]' % (node.fullPath(), i)
                    )

            caller.step()

        if len(faces_with_zero_uv_area) == 0:
            pm.warning('No Zero UV area polys found!!!')
            return []
        else:
            pm.select(faces_with_zero_uv_area)
            return faces_with_zero_uv_area
Пример #10
0
    def test_register_will_return_a_progress_caller_instance(self):
        """testing if the ProgressDialogManager.register() method will return a
        ProgressCaller instance
        """
        pm = ProgressDialogManager()
        caller = pm.register(10)
        self.assertIsInstance(caller, ProgressCaller)

        self.assertEqual(caller.max_steps, 10)
        self.assertEqual(caller.current_step, 0)
Пример #11
0
    def test_register_will_return_a_progress_caller_instance(self):
        """testing if the ProgressDialogManager.register() method will return a
        ProgressCaller instance
        """
        pm = ProgressDialogManager()
        caller = pm.register(10)
        self.assertIsInstance(caller, ProgressCaller)

        self.assertEqual(caller.max_steps, 10)
        self.assertEqual(caller.current_step, 0)
Пример #12
0
 def test_end_progress_will_close_dialog_if_there_are_no_callers_left(self):
     """testing if the end_progress method will close the progress dialog
     it there are no callers left
     """
     pm = ProgressDialogManager()
     caller = pm.register(5)
     caller.step()
     self.assertIn(caller, pm.callers)
     pm.end_progress(caller)
     self.assertNotIn(caller, pm.callers)
Пример #13
0
 def test_end_progress_method_removes_the_given_caller_from_list(self):
     """testing if the end_progress method will remove the given caller from
     the callers list
     """
     pm = ProgressDialogManager()
     caller = pm.register(5)
     caller.step()
     self.assertIn(caller, pm.callers)
     pm.end_progress(caller)
     self.assertNotIn(caller, pm.callers)
Пример #14
0
 def test_end_progress_will_close_dialog_if_there_are_no_callers_left(self):
     """testing if the end_progress method will close the progress dialog
     it there are no callers left
     """
     pm = ProgressDialogManager()
     caller = pm.register(5)
     caller.step()
     self.assertIn(caller, pm.callers)
     pm.end_progress(caller)
     self.assertNotIn(caller, pm.callers)
Пример #15
0
 def test_end_progress_method_removes_the_given_caller_from_list(self):
     """testing if the end_progress method will remove the given caller from
     the callers list
     """
     pm = ProgressDialogManager()
     caller = pm.register(5)
     caller.step()
     self.assertIn(caller, pm.callers)
     pm.end_progress(caller)
     self.assertNotIn(caller, pm.callers)
Пример #16
0
def check_uvs():
    """checks uvs with no uv area

    The area of a 2d polygon calculation is based on the answer of Darius Bacon
    in http://stackoverflow.com/questions/451426/how-do-i-calculate-the-surface-area-of-a-2d-polygon
    """

    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    def area(p):
        return 0.5 * abs(
            sum(x0 * y1 - x1 * y0 for ((x0, y0), (x1, y1)) in segments(p)))

    def segments(p):
        return zip(p, p[1:] + [p[0]])

    all_meshes = pm.ls(type='mesh')
    mesh_count = len(all_meshes)

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    if not pm.general.about(batch=1) and mesh_count:
        pdm.use_ui = True

    caller = pdm.register(mesh_count, 'check_uvs()')

    meshes_with_zero_uv_area = []
    for node in all_meshes:
        all_uvs = node.getUVs()
        try:
            for i in range(node.numFaces()):
                uvs = []
                for j in range(node.numPolygonVertices(i)):
                    # uvs.append(node.getPolygonUV(i, j))
                    uv_id = node.getPolygonUVid(i, j)
                    uvs.append((all_uvs[0][uv_id], all_uvs[1][uv_id]))
                if area(uvs) == 0.0:
                    meshes_with_zero_uv_area.append(node)
                    break
        except RuntimeError:
            meshes_with_zero_uv_area.append(node)

        caller.step()

    if len(meshes_with_zero_uv_area):
        pm.select([node.getParent() for node in meshes_with_zero_uv_area])
        raise RuntimeError(
            """There are meshes with no uvs or faces with zero uv area:<br><br>
            %s""" % '<br>'.join(
                map(lambda x: x.name(),
                    meshes_with_zero_uv_area[:MAX_NODE_DISPLAY])))
Пример #17
0
    def test_step_will_increment_the_call_count_of_the_given_caller(self):
        """testing if the step method will increment the step of the caller
        """
        pm = ProgressDialogManager()
        caller = pm.register(100)
        self.assertEqual(caller.current_step, 0)

        pm.step(caller)
        self.assertEqual(caller.current_step, 1)

        pm.step(caller)
        self.assertEqual(caller.current_step, 2)
Пример #18
0
    def test_step_will_increment_the_call_count_of_the_given_caller(self):
        """testing if the step method will increment the step of the caller
        """
        pm = ProgressDialogManager()
        caller = pm.register(100)
        self.assertEqual(caller.current_step, 0)

        pm.step(caller)
        self.assertEqual(caller.current_step, 1)

        pm.step(caller)
        self.assertEqual(caller.current_step, 2)
Пример #19
0
    def test_step_will_step_the_progress_dialog(self):
        """testing if the step method will call QProgressDialog.setRange()
        properly
        """
        pm = ProgressDialogManager()
        caller = pm.register(5, "test title")
        pm.step(caller, 2)

        self.assertIn("setRange", pm.dialog.call_info)

        # check the values
        self.assertEqual(pm.dialog.call_info["setRange"], [(0, 5), {}])
        self.assertEqual(pm.dialog.call_info["setValue"], [(2,), {}])
Пример #20
0
    def test_step_will_step_the_progress_dialog(self):
        """testing if the step method will call QProgressDialog.setRange()
        properly
        """
        pm = ProgressDialogManager()
        caller = pm.register(5, 'test title')
        pm.step(caller, 2)

        self.assertIn('setRange', pm.dialog.call_info)

        # check the values
        self.assertEqual(pm.dialog.call_info['setRange'], [(0, 5), {}])
        self.assertEqual(pm.dialog.call_info['setValue'], [(2, ), {}])
Пример #21
0
    def test_step_will_set_the_dialog_title(self):
        """testing if the step method will set the dialog title to the stepped
        caller
        """
        pm = ProgressDialogManager()
        test_title1 = "test title 1"
        test_title2 = "test title 2"
        caller1 = pm.register(5, test_title1)
        caller2 = pm.register(5, test_title2)
        pm.step(caller1)
        self.assertEqual(pm.dialog.call_info["setLabelText"], [("%s : " % test_title1,), {}])

        pm.step(caller2)
        self.assertEqual(pm.dialog.call_info["setLabelText"], [("%s : " % test_title2,), {}])
Пример #22
0
def check_component_edits_on_references():
    """check if there are component edits on references
    """
    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    import maya.cmds
    reference_query = maya.cmds.referenceQuery

    references_with_component_edits = []

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    all_refs = pm.listReferences(recursive=True)
    ref_count = len(all_refs)

    if not pm.general.about(batch=1) and ref_count:
        pdm.use_ui = True

    caller = pdm.register(
        ref_count,
        'Checking component edits on %i reference nodes' % ref_count
    )

    for ref in all_refs:
        all_edits = reference_query(ref.refNode.name(), es=True)
        # joined_edits = '\n'.join(all_edits)
        # if '.pt[' in joined_edits or '.pnts[' in joined_edits:
        #     references_with_component_edits.append(ref)
        for edit in all_edits:
            if '.pt[' in edit or '.pnts[' in edit:
                references_with_component_edits.append(ref)
                break
        caller.step()

    caller.end_progress()

    if len(references_with_component_edits):
        raise PublishError(
            'There are <b>component edits</b> on the following References:'
            '<br><br>%s<br><br>Please remove them!!!' %
            '<br>'.join(
                map(lambda x: x.refNode.name(),
                    references_with_component_edits[:MAX_NODE_DISPLAY])
            )
        )
Пример #23
0
    def test_step_will_set_the_dialog_title(self):
        """testing if the step method will set the dialog title to the stepped
        caller
        """
        pm = ProgressDialogManager()
        test_title1 = 'test title 1'
        test_title2 = 'test title 2'
        caller1 = pm.register(5, test_title1)
        caller2 = pm.register(5, test_title2)
        pm.step(caller1)
        self.assertEqual(pm.dialog.call_info['setLabelText'],
                         [('%s : ' % test_title1, ), {}])

        pm.step(caller2)
        self.assertEqual(pm.dialog.call_info['setLabelText'],
                         [('%s : ' % test_title2, ), {}])
Пример #24
0
    def test_step_removes_the_given_caller_if_it_is_at_maximum(self):
        """testing if the step method will automatically remove the caller from
        the list if the caller reached to its maximum
        """
        pm = ProgressDialogManager()
        self.assertFalse(pm.in_progress)
        caller = pm.register(5)
        self.assertTrue(pm.in_progress)
        self.assertEqual(caller.current_step, 0)
        self.assertTrue(pm.in_progress)
        self.assertIn(caller, pm.callers)

        for i in range(5):
            caller.step()

        self.assertNotIn(caller, pm.callers)
        self.assertFalse(pm.in_progress)
Пример #25
0
    def test_step_removes_the_given_caller_if_it_is_at_maximum(self):
        """testing if the step method will automatically remove the caller from
        the list if the caller reached to its maximum
        """
        pm = ProgressDialogManager()
        self.assertFalse(pm.in_progress)
        caller = pm.register(5)
        self.assertTrue(pm.in_progress)
        self.assertEqual(caller.current_step, 0)
        self.assertTrue(pm.in_progress)
        self.assertIn(caller, pm.callers)

        for i in range(5):
            caller.step()

        self.assertNotIn(caller, pm.callers)
        self.assertFalse(pm.in_progress)
Пример #26
0
def check_component_edits_on_references():
    """check if there are component edits on references
    """
    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    import maya.cmds
    reference_query = maya.cmds.referenceQuery

    references_with_component_edits = []

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    all_refs = pm.listReferences(recursive=True)
    ref_count = len(all_refs)

    if not pm.general.about(batch=1) and ref_count:
        pdm.use_ui = True

    caller = pdm.register(
        ref_count,
        'Checking component edits on %i reference nodes' % ref_count)

    for ref in all_refs:
        all_edits = reference_query(ref.refNode.name(), es=True)
        # joined_edits = '\n'.join(all_edits)
        # if '.pt[' in joined_edits or '.pnts[' in joined_edits:
        #     references_with_component_edits.append(ref)
        for edit in all_edits:
            if '.pt[' in edit or '.pnts[' in edit:
                references_with_component_edits.append(ref)
                break
        caller.step()

    caller.end_progress()

    if len(references_with_component_edits):
        raise PublishError(
            'There are <b>component edits</b> on the following References:'
            '<br><br>%s<br><br>Please remove them!!!' % '<br>'.join(
                map(lambda x: x.refNode.name(),
                    references_with_component_edits[:MAX_NODE_DISPLAY])))
Пример #27
0
def check_out_of_space_uvs():
    """checks if there are uvs with u values that are bigger than 10.0
    """

    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    all_meshes = pm.ls(type='mesh')
    mesh_count = len(all_meshes)
    nodes_with_out_of_space_uvs = []

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    if not pm.general.about(batch=1) and mesh_count:
        pdm.use_ui = True

    caller = pdm.register(mesh_count, 'check_out_of_space_uvs()')

    for node in all_meshes:
        u, v = node.getUVs()
        u = sorted(u)
        if u[0] < 0.0 or u[-1] > 10.0 or v[0] < 0.0:
            nodes_with_out_of_space_uvs.append(node)

        caller.step()

    if len(nodes_with_out_of_space_uvs):
        # get transform nodes
        tra_nodes = map(
            lambda x: x.getParent(),
            nodes_with_out_of_space_uvs
        )
        pm.select(tra_nodes)
        raise RuntimeError(
            """There are nodes which have a UV value bigger than <b>10</b>:
            <br><br>%s""" %
            '<br>'.join(
                map(lambda x: x.name(),
                    tra_nodes[:MAX_NODE_DISPLAY])
            )
        )
Пример #28
0
def check_out_of_space_uvs():
    """checks if there are uvs with u values that are bigger than 10.0
    """

    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    all_meshes = pm.ls(type='mesh')
    mesh_count = len(all_meshes)
    nodes_with_out_of_space_uvs = []

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    if not pm.general.about(batch=1) and mesh_count:
        pdm.use_ui = True

    caller = pdm.register(mesh_count, 'check_out_of_space_uvs()')

    for node in all_meshes:
        u, v = node.getUVs()
        u = sorted(u)
        if u[0] < 0.0 or u[-1] > 10.0 or v[0] < 0.0:
            nodes_with_out_of_space_uvs.append(node)

        caller.step()

    if len(nodes_with_out_of_space_uvs):
        # get transform nodes
        tra_nodes = map(lambda x: x.getParent(), nodes_with_out_of_space_uvs)
        pm.select(tra_nodes)
        raise RuntimeError(
            """There are nodes which have a UV value bigger than <b>10</b>:
            <br><br>%s""" %
            '<br>'.join(map(lambda x: x.name(), tra_nodes[:MAX_NODE_DISPLAY])))
Пример #29
0
    def save_previs_to_shots(self, take_name):
        """exports previs to animation shots
        """
        self.pre_publish_previs()

        shot_tasks = self.scene_shot_tasks
        shot_nodes = self.shot_list
        shots_to_export = []

        for shot_node in shot_nodes:
            for shot_task in shot_tasks:
                for task in shot_task.tasks:
                    if task.type == self.anim_type:
                        shot_number = shot_task.name.split('_')[-1]
                        if shot_node.getShotName() == shot_number:
                            shots_to_export.append([shot_node, task, shot_number])

        from anima.env import mayaEnv
        from stalker import Version
        from anima.ui.progress_dialog import ProgressDialogManager
        pdm = ProgressDialogManager()
        pdm.close()

        m_env = mayaEnv.Maya()

        versions = []
        description = 'Auto Created By Shot Exporter'
        # create versions to save and show in pop-up window
        for shot_info in shots_to_export:
            version = Version(
                task=shot_info[1],
                description=description,
                take_name=take_name,
                created_by=self.logged_in_user
            )
            versions.append(version)

        if len(versions) != len(shots_to_export):
            from stalker.db.session import DBSession
            DBSession.rollback()
            raise RuntimeError('Something is critically wrong. Contact Mehmet ERER.')

        # pop-up a window to show everything will be saved properly before actually doing it
        message = 'Shots will be Saved as Below:\r\n'
        message += '\r'
        index = 0
        for shot_info in shots_to_export:
            v = versions[index]
            message += 'shot[ %s ] -> %s\n' % (shot_info[2], v)
            index += 1
        dialog = pm.confirmDialog(title='Important Warning',
                                  message=message,
                                  button=['OK, Start Saving Shots', 'STOP, wrong paths!'])
        if dialog == 'OK, Start Saving Shots':
            pass
        else:
            from stalker.db.session import DBSession
            DBSession.rollback()
            raise RuntimeError('Process Interrupted by User.')

        previs_version = self.current_version

        errored_shots = []
        ind = 0
        caller = pdm.register(len(shots_to_export), 'Batch Saving Previs Shot Nodes to Animation Shot Tasks...')
        from anima.env.mayaEnv import toolbox
        reload(toolbox)
        from stalker.db.session import DBSession
        for shot_info in shots_to_export:
            shot_task = versions[ind].task.parent
            try:
                # open previs version
                m_env.open(previs_version, force=True, reference_depth=3, skip_update_check=True)

                # clear scene
                except_this_shot = pm.PyNode(shot_info[0].name())
                self.clear_scene(except_this_shot)

                # set frame range before save
                toolbox.Animation.set_range_from_shot()

                # update shot.cut_in and shot.cut_out info
                cut_in = pm.playbackOptions(q=1, min=1)
                cut_out = pm.playbackOptions(q=1, max=1)
                shot_task.cut_in = int(cut_in)
                shot_task.cut_out = int(cut_out)

                # save it
                m_env.save_as(versions[ind])
            except:
                errored_shots.append(shot_info[2])
            else:
                # store information to database
                DBSession.add(shot_task)
                DBSession.add(versions[ind])
                DBSession.commit()
            ind += 1

            caller.step()

        if errored_shots:
            message = 'Shots could not be saved:\r\n'
            message += '\r'
            for shot in errored_shots:
                message += '[ %s ]\n' % shot
            pm.confirmDialog(title='Error', message=message, button='OK')
            DBSession.rollback()
            raise RuntimeError('Some Shots could not be saved. Contact Mehmet ERER.')

        # leave it as empty new file
        pm.newFile(force=True)
        message = 'Previs to Shots\r\n'
        message += '\r'
        message += 'Completed Succesfully.\r\n'
        pm.confirmDialog(title='Info', message=message, button='OK')
Пример #30
0
def export_edl():
    """exports edl of animation scenes
    """
    from anima.env.mayaEnv import Maya
    m = Maya()
    current_version = m.get_current_version()

    if not current_version:
        return

    # get sequenceManager1
    sm = pm.PyNode('sequenceManager1')
    seqs = sm.sequences.get()
    if not len(seqs):
        return

    seq1 = seqs[0]

    edl_path = tempfile.gettempdir()
    edl_file_name = '%s_v%03i.edl' % (current_version.nice_name,
                                      current_version.version_number)

    edl_file_full_path = os.path.join(edl_path, edl_file_name)

    # convert to MXF
    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    #shots = seq1.shots.get()
    shots = pm.ls(type='shot')
    shot_count = len(shots)

    # before doing a playblast set all shot handles to 48
    for shot in pm.ls(type='shot'):
        if shot.hasAttr('handle'):
            shot.handle.set(48)

    caller = pdm.register(shot_count, title='Converting To MXF')

    # update shot outputs to the correct place first
    # there should be only one shot in the current animation scene
    # if there is more than one shot, the other publisher will already warn the
    # user so the code path will not reach to this point

    # we also should already have a video output created by another publisher
    playblast_file = None
    for output in current_version.outputs:
        extension = os.path.splitext(output.full_path)[-1]
        if extension in ['.mov', '.avi', '.mp4']:
            playblast_file = output
            break

    if not playblast_file:
        return
    shot = shots[0]
    shot.output.set(playblast_file.full_path)

    for i in seq1.metafuze():
        caller.step()

    # create EDL file
    from anima import utils
    mm = utils.MediaManager()
    l = sm.to_edl()
    with open(edl_file_full_path, 'w') as f:
        f.write(l.to_string())

    with open(edl_file_full_path, 'r') as f:
        link = mm.upload_version_output(current_version, f, edl_file_name)

    # add the link to database
    from stalker import db
    db.DBSession.commit()

    # revert the handles to 0
    for shot in pm.ls(type='shot'):
        if shot.hasAttr('handle'):
            shot.handle.set(0)
Пример #31
0
def check_uv_border_crossing():
    """checks if any of the uv shells are crossing uv borders
    """
    # skip if this is a representation
    v = staging.get('version')
    if v and Representation.repr_separator in v.take_name:
        return

    all_meshes = pm.ls(type='mesh')
    mesh_count = len(all_meshes)

    nodes_with_uvs_crossing_borders = []

    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    if not pm.general.about(batch=1) and mesh_count:
        pdm.use_ui = True

    caller = pdm.register(mesh_count, 'check_out_of_space_uvs()')

    for node in all_meshes:
        all_uvs = node.getUVs()
        uv_shell_ids = node.getUvShellsIds()

        # prepare an empty dict of lists
        uvs_per_shell = {}
        for shell_id in range(uv_shell_ids[1]):
            uvs_per_shell[shell_id] = [[], []]

        for uv_id in range(len(uv_shell_ids[0])):
            u = all_uvs[0][uv_id]
            v = all_uvs[1][uv_id]
            shell_id = uv_shell_ids[0][uv_id]

            uvs_per_shell[shell_id][0].append(u)
            uvs_per_shell[shell_id][1].append(v)

        # now check all uvs per shell
        for shell_id in range(uv_shell_ids[1]):
            us = sorted(uvs_per_shell[shell_id][0])
            vs = sorted(uvs_per_shell[shell_id][1])

            # check first and last u and v values
            if int(us[0]) != int(us[-1]) or int(vs[0]) != int(vs[-1]):
                # they are not equal it is crossing spaces
                nodes_with_uvs_crossing_borders.append(node)
                break

        caller.step()

    if len(nodes_with_uvs_crossing_borders):
        # get transform nodes
        tra_nodes = map(
            lambda x: x.getParent(),
            nodes_with_uvs_crossing_borders
        )
        pm.select(tra_nodes)
        raise RuntimeError(
            """There are nodes with <b>UV-Shells</b> that are crossing
            <b>UV BORDERS</b>:<br><br>%s""" %
            '<br>'.join(
                map(lambda x: x.name(),
                    tra_nodes[:MAX_NODE_DISPLAY])
            )
        )
Пример #32
0
def export_edl():
    """exports edl of animation scenes
    """
    from anima.env.mayaEnv import Maya
    m = Maya()
    current_version = m.get_current_version()

    if not current_version:
        return

    # get sequenceManager1
    sm = pm.PyNode('sequenceManager1')
    seqs = sm.sequences.get()
    if not len(seqs):
        return

    seq1 = seqs[0]

    edl_path = tempfile.gettempdir()
    edl_file_name = '%s_v%03i.edl' % (
        current_version.nice_name,
        current_version.version_number
    )

    edl_file_full_path = os.path.join(edl_path, edl_file_name)

    # convert to MXF
    from anima.ui.progress_dialog import ProgressDialogManager
    pdm = ProgressDialogManager()

    #shots = seq1.shots.get()
    shots = pm.ls(type='shot')
    shot_count = len(shots)

    # before doing a playblast set all shot handles to 48
    for shot in pm.ls(type='shot'):
        if shot.hasAttr('handle'):
            shot.handle.set(48)

    caller = pdm.register(shot_count, title='Converting To MXF')

    # update shot outputs to the correct place first
    # there should be only one shot in the current animation scene
    # if there is more than one shot, the other publisher will already warn the
    # user so the code path will not reach to this point

    # we also should already have a video output created by another publisher
    playblast_file = None
    for output in current_version.outputs:
        extension = os.path.splitext(output.full_path)[-1]
        if extension in ['.mov', '.avi', '.mp4']:
            playblast_file = output
            break

    if not playblast_file:
        return
    shot = shots[0]
    shot.output.set(playblast_file.full_path)

    for i in seq1.metafuze():
        caller.step()

    # create EDL file
    from anima import utils
    mm = utils.MediaManager()
    l = sm.to_edl()
    with open(edl_file_full_path, 'w') as f:
        f.write(l.to_string())

    with open(edl_file_full_path, 'r') as f:
        link = mm.upload_version_output(current_version, f, edl_file_name)

    # add the link to database
    from stalker import db
    db.DBSession.commit()

    # revert the handles to 0
    for shot in pm.ls(type='shot'):
        if shot.hasAttr('handle'):
            shot.handle.set(0)
Пример #33
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
Пример #34
0
    def generate_repr_of_all_references(cls,
                                        generate_gpu=True,
                                        generate_ass=True,
                                        generate_rs=True,
                                        skip_existing=False):
        """generates all representations of all references of this scene
        """
        from anima.ui.progress_dialog import ProgressDialogManager
        from anima.env.mayaEnv import Maya, repr_tools, auxiliary
        reload(auxiliary)
        reload(repr_tools)

        paths_visited = []
        versions_to_visit = []
        versions_cannot_be_published = []

        # generate a sorted version list
        # and visit each reference only once
        from anima.env.mayaEnv import MayaMainProgressBarWrapper
        wrp = MayaMainProgressBarWrapper()
        pdm = ProgressDialogManager(dialog=wrp)

        use_progress_window = False
        if not pm.general.about(batch=1):
            use_progress_window = True

        all_refs = pm.listReferences(recursive=True)

        pdm.use_ui = use_progress_window
        caller = pdm.register(len(all_refs), 'List References')

        for ref in reversed(all_refs):
            ref_path = str(ref.path)
            caller.step(message=ref_path)
            if ref_path not in paths_visited:
                v = ref.version
                if v is not None:
                    paths_visited.append(ref_path)
                    versions_to_visit.append(v)

        response = pm.confirmDialog(
            title='Do Create Representations?',
            message='Create all Repr. for all %s FileReferences?'
                    % len(versions_to_visit),
            button=['Yes', 'No'],
            defaultButton='No',
            cancelButton='No',
            dismissString='No'
        )
        if response == 'No':
            return

        # register a new caller
        caller = pdm.register(max_iteration=len(versions_to_visit),
                              title='Generate Reprs')

        m_env = Maya()
        source_version = m_env.get_current_version()
        gen = repr_tools.RepresentationGenerator()

        # open each version
        from stalker import Version
        for v in versions_to_visit:
            local_generate_gpu = generate_gpu
            local_generate_ass = generate_ass
            local_generate_rs = generate_rs

            # check if this is a repr
            if '@' in v.take_name:
                # use the parent
                v = v.parent
                if not v:
                    continue

            if skip_existing:
                # check if there is a GPU or ASS repr
                # generated from this version
                child_versions = Version.query.filter(Version.parent == v).all()
                for cv in child_versions:
                    if local_generate_gpu is True and '@GPU' in cv.take_name:
                        local_generate_gpu = False

                    if local_generate_ass is True and '@ASS' in cv.take_name:
                        local_generate_ass = False

                    if local_generate_rs is True and '@RS' in cv.take_name:
                        local_generate_rs = False

            gen.version = v
            # generate representations
            if local_generate_gpu:
                try:
                    gen.generate_gpu()
                except RuntimeError:
                    if v not in versions_cannot_be_published:
                        versions_cannot_be_published.append(v)

            if local_generate_ass:
                try:
                    gen.generate_ass()
                except RuntimeError:
                    if v not in versions_cannot_be_published:
                        versions_cannot_be_published.append(v)

            if local_generate_rs:
                try:
                    gen.generate_rs()
                except RuntimeError:
                    if v not in versions_cannot_be_published:
                        versions_cannot_be_published.append(v)

            caller.step()

        # now open the source version again
        m_env.open(source_version, force=True, skip_update_check=True)

        # and generate representation for the source
        gen.version = source_version

        # generate representations
        if not versions_cannot_be_published:
            if generate_gpu:
                gen.generate_gpu()
            if generate_ass:
                gen.generate_ass()
            if generate_rs:
                gen.generate_rs()
        else:
            pm.confirmDialog(
                title='Error',
                message='The following versions can not be published '
                        '(check script editor):\n\n%s' % (
                            '\n'.join(
                                map(lambda x: x.nice_name,
                                    versions_cannot_be_published)
                            )
                        ),
                button=['OK'],
                defaultButton='OK',
                cancelButton='OK',
                dismissString='OK'
            )

            pm.error(
                '\n'.join(
                    map(lambda x: x.absolute_full_path,
                        versions_cannot_be_published)
                )
            )
Пример #35
0
    def generate_repr_of_scene(cls,
                               generate_gpu=True,
                               generate_ass=True,
                               generate_rs=True,
                               skip_existing=False):
        """generates desired representations of this scene
        """
        from anima.ui.progress_dialog import ProgressDialogManager
        from anima.env.mayaEnv import Maya, repr_tools, auxiliary
        reload(auxiliary)
        reload(repr_tools)

        response = pm.confirmDialog(
            title='Do Create Representations?',
            message='Create all Repr. for this scene?',
            button=['Yes', 'No'],
            defaultButton='No',
            cancelButton='No',
            dismissString='No'
        )
        if response == 'No':
            return

        # register a new caller
        from anima.env.mayaEnv import MayaMainProgressBarWrapper
        wrp = MayaMainProgressBarWrapper()
        pdm = ProgressDialogManager(dialog=wrp)

        m_env = Maya()
        source_version = m_env.get_current_version()
        gen = repr_tools.RepresentationGenerator()

        # open each version
        from stalker import Version
        if skip_existing:
            # check if there is a GPU or ASS repr
            # generated from this version
            child_versions = \
                Version.query.filter(Version.parent == source_version).all()
            for cv in child_versions:
                if generate_gpu is True and '@GPU' in cv.take_name:
                    generate_gpu = False

                if generate_ass is True and '@ASS' in cv.take_name:
                    generate_ass = False

                if generate_rs is True and '@RS' in cv.take_name:
                    generate_rs = False

        total_number_of_reprs = generate_gpu + generate_ass + generate_rs
        caller = pdm.register(total_number_of_reprs, title='Generate Reprs')

        gen.version = source_version
        # generate representations
        if generate_gpu:
            gen.generate_gpu()
            caller.step()

        if generate_ass:
            gen.generate_ass()
            caller.step()

        if generate_rs:
            gen.generate_rs()
            caller.step()

        # now open the source version again
        m_env.open(source_version, force=True, skip_update_check=True)
Пример #36
0
    def save_previs_to_shots(self, take_name):
        """exports previs to animation shots
        """
        self.pre_publish_previs()

        shot_tasks = self.scene_shot_tasks
        shot_nodes = self.shot_list
        shots_to_export = []

        for shot_node in shot_nodes:
            for shot_task in shot_tasks:
                for task in shot_task.tasks:
                    if task.type == self.anim_type:
                        shot_number = shot_task.name.split('_')[-1]
                        if shot_node.getShotName() == shot_number:
                            shots_to_export.append(
                                [shot_node, task, shot_number])

        from anima.env import mayaEnv
        from stalker import Version
        from anima.ui.progress_dialog import ProgressDialogManager
        pdm = ProgressDialogManager()
        pdm.close()

        m_env = mayaEnv.Maya()

        versions = []
        description = 'Auto Created By Shot Exporter'
        # create versions to save and show in pop-up window
        for shot_info in shots_to_export:
            version = Version(task=shot_info[1],
                              description=description,
                              take_name=take_name,
                              created_by=self.logged_in_user)
            versions.append(version)

        if len(versions) != len(shots_to_export):
            from stalker.db.session import DBSession
            DBSession.rollback()
            raise RuntimeError(
                'Something is critically wrong. Contact Mehmet ERER.')

        # pop-up a window to show everything will be saved properly before actually doing it
        message = 'Shots will be Saved as Below:\r\n'
        message += '\r'
        index = 0
        for shot_info in shots_to_export:
            v = versions[index]
            message += 'shot[ %s ] -> %s\n' % (shot_info[2], v)
            index += 1
        dialog = pm.confirmDialog(
            title='Important Warning',
            message=message,
            button=['OK, Start Saving Shots', 'STOP, wrong paths!'])
        if dialog == 'OK, Start Saving Shots':
            pass
        else:
            from stalker.db.session import DBSession
            DBSession.rollback()
            raise RuntimeError('Process Interrupted by User.')

        previs_version = self.current_version

        errored_shots = []
        ind = 0
        caller = pdm.register(
            len(shots_to_export),
            'Batch Saving Previs Shot Nodes to Animation Shot Tasks...')
        from anima.env.mayaEnv import toolbox
        from stalker.db.session import DBSession
        for shot_info in shots_to_export:
            shot_task = versions[ind].task.parent
            try:
                # open previs version
                m_env.open(previs_version,
                           force=True,
                           reference_depth=3,
                           skip_update_check=True)

                # clear scene
                except_this_shot = pm.PyNode(shot_info[0].name())
                self.clear_scene(except_this_shot)

                # set frame range before save
                anima.env.mayaEnv.animation.Animation.set_range_from_shot()

                # update shot.cut_in and shot.cut_out info
                cut_in = pm.playbackOptions(q=1, min=1)
                cut_out = pm.playbackOptions(q=1, max=1)
                shot_task.cut_in = int(cut_in)
                shot_task.cut_out = int(cut_out)

                # save it
                m_env.save_as(versions[ind])
            except:
                errored_shots.append(shot_info[2])
            else:
                # store information to database
                DBSession.add(shot_task)
                DBSession.add(versions[ind])
                DBSession.commit()
            ind += 1

            caller.step()

        if errored_shots:
            message = 'Shots could not be saved:\r\n'
            message += '\r'
            for shot in errored_shots:
                message += '[ %s ]\n' % shot
            pm.confirmDialog(title='Error', message=message, button='OK')
            DBSession.rollback()
            raise RuntimeError(
                'Some Shots could not be saved. Contact Mehmet ERER.')

        # leave it as empty new file
        pm.newFile(force=True)
        message = 'Previs to Shots\r\n'
        message += '\r'
        message += 'Completed Succesfully.\r\n'
        pm.confirmDialog(title='Info', message=message, button='OK')
Пример #37
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