def __init__(self, name='TestEnv'): EnvironmentBase.__init__(self, name=name) # initialize test_data counter for f in dir(self): if callable(f): self.test_data[f.__name__] = {"call count": 0, "data": None} self._version = None
def test_get_versions_from_path_handles_empty_and_None_path(self): """testing if no errors will be raised for a path which is None or an empty string """ env = EnvironmentBase() versions = env.get_versions_from_path("") self.assertEqual(versions, []) versions = env.get_versions_from_path(None) self.assertEqual(versions, [])
def test_get_versions_from_path_handles_empty_and_None_path(self): """testing if no errors will be raised for a path which is None or an empty string """ env = EnvironmentBase() versions = env.get_versions_from_path('') self.assertEqual(versions, []) versions = env.get_versions_from_path(None) self.assertEqual(versions, [])
def __init__(self, version=None): EnvironmentBase.__init__(self, self.name, version)
def test_get_version_from_full_path_with_multiple_repositories(self): """testing if the get version from full path is working fine with multiple repositories and with same version names """ repo1 = Repository(name="Test Repo 1", linux_path="/mnt/T/", windows_path="T:/", osx_path="/Volumes/T/") DBSession.add(repo1) repo2 = Repository(name="Test Repo 2", linux_path="/mnt/S/", windows_path="S:/", osx_path="/Volumes/S/") DBSession.add(repo2) task_ft = FilenameTemplate( name="Task Filename Template", target_entity_type="Task", path="$REPO{{project.repository.id}}/{{project.code}}/" "{%- for parent_task in parent_tasks -%}" "{{parent_task.nice_name}}/{%- endfor -%}", filename="{{task.nice_name}}_{{version.take_name}}" '_v{{"%03d"|format(version.version_number)}}', ) DBSession.add(task_ft) structure1 = Structure(name="Commercial Project Structure", templates=[task_ft]) DBSession.add(structure1) status1 = Status(name="Status 1", code="STS1") status2 = Status(name="Status 2", code="STS2") status3 = Status(name="Status 3", code="STS3") DBSession.add_all([status1, status2, status3]) proj_status_list = StatusList( name="Project Statuses", target_entity_type="Project", statuses=[status1, status2, status3] ) DBSession.add(proj_status_list) task_status_list = StatusList( name="Task Statuses", target_entity_type="Task", statuses=[status1, status2, status3] ) DBSession.add(task_status_list) version_status_list = StatusList( name="Version Statuses", target_entity_type="Version", statuses=[status1, status2, status3] ) DBSession.add(version_status_list) project1 = Project( name="Test Project 1", code="TP1", repositories=[repo1], structure=structure1, status_list=proj_status_list ) DBSession.add(project1) project2 = Project( name="Test Project 2", code="TP2", repositories=[repo2], structure=structure1, status_list=proj_status_list ) DBSession.add(project2) task1 = Task(name="Test Task 1", code="TT1", project=project1, status_list=task_status_list) DBSession.add(task1) task2 = Task(name="Test Task 1", code="TT1", project=project2, status_list=task_status_list) DBSession.add(task2) DBSession.commit() # now create versions version1 = Version(task=task1, status_list=version_status_list) DBSession.add(version1) DBSession.commit() version1.update_paths() version2 = Version(task=task2, status_list=version_status_list) DBSession.add(version2) DBSession.commit() version2.update_paths() DBSession.commit() logger.debug("version1.full_path : %s" % version1.full_path) logger.debug("version2.full_path : %s" % version2.full_path) # now try to get the versions with an EnvironmentBase instance env = EnvironmentBase() # version1 version1_found = env.get_version_from_full_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version1_found, version1) # version2 version2_found = env.get_version_from_full_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version2_found, version2) # version1 in windows version1_found = env.get_version_from_full_path("T:/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version1_found, version1) # version2 in windows version2_found = env.get_version_from_full_path("S:/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version2_found, version2) # version1 in linux version1_found = env.get_version_from_full_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version1_found, version1) # version2 in linux version2_found = env.get_version_from_full_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version2_found, version2) # version1 in osx version1_found = env.get_version_from_full_path("/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version1_found, version1) # version2 in osx version2_found = env.get_version_from_full_path("/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(version2_found, version2)
def test_trim_repo_path_with_multiple_repositories(self): """testing if the trim_repo_path is working fine with multiple repositories and with same version names """ repo0 = Repository( name="Test Repo 0", linux_path="/mnt/T/with_a_very_long_path_which_will_cause_errors/", windows_path="T:/with_a_very_long_path_which_will_cause_errors/", osx_path="/Volumes/T/" "with_a_very_long_path_which_will_cause_errors/", ) DBSession.add(repo0) repo1 = Repository(name="Test Repo 1", linux_path="/mnt/T/", windows_path="T:/", osx_path="/Volumes/T/") DBSession.add(repo1) repo2 = Repository(name="Test Repo 2", linux_path="/mnt/S/", windows_path="S:/", osx_path="/Volumes/S/") DBSession.add(repo2) task_ft = FilenameTemplate( name="Task Filename Template", target_entity_type="Task", path="{{project.code}}/{%- for parent_task in parent_tasks -%}" "{{parent_task.nice_name}}/{%- endfor -%}", filename="{{task.nice_name}}_{{version.take_name}}" '_v{{"%03d"|format(version.version_number)}}', ) DBSession.add(task_ft) structure1 = Structure(name="Commercial Project Structure", templates=[task_ft]) DBSession.add(structure1) status1 = Status(name="Status 1", code="STS1") status2 = Status(name="Status 2", code="STS2") status3 = Status(name="Status 3", code="STS3") DBSession.add_all([status1, status2, status3]) proj_status_list = StatusList( name="Project Statuses", target_entity_type="Project", statuses=[status1, status2, status3] ) DBSession.add(proj_status_list) task_status_list = StatusList( name="Task Statuses", target_entity_type="Task", statuses=[status1, status2, status3] ) DBSession.add(task_status_list) version_status_list = StatusList( name="Version Statuses", target_entity_type="Version", statuses=[status1, status2, status3] ) DBSession.add(version_status_list) project1 = Project( name="Test Project 1", code="TP1", repositories=[repo1], structure=structure1, status_list=proj_status_list ) DBSession.add(project1) project2 = Project( name="Test Project 2", code="TP2", repositories=[repo2], structure=structure1, status_list=proj_status_list ) DBSession.add(project2) task1 = Task(name="Test Task 1", code="TT1", project=project1, status_list=task_status_list) DBSession.add(task1) task2 = Task(name="Test Task 1", code="TT1", project=project2, status_list=task_status_list) DBSession.add(task2) DBSession.commit() # now create versions version1 = Version(task=task1, status_list=version_status_list) DBSession.add(version1) DBSession.commit() version1.update_paths() version2 = Version(task=task1, status_list=version_status_list) DBSession.add(version2) DBSession.commit() version2.update_paths() version3 = Version(task=task2, status_list=version_status_list) DBSession.add(version3) DBSession.commit() version3.update_paths() version4 = Version(task=task2, status_list=version_status_list) DBSession.add(version4) DBSession.commit() version4.update_paths() DBSession.commit() logger.debug("version1.full_path : %s" % version1.full_path) logger.debug("version2.full_path : %s" % version2.full_path) logger.debug("version3.full_path : %s" % version2.full_path) logger.debug("version4.full_path : %s" % version2.full_path) # now try to get the versions with an EnvironmentBase instance env = EnvironmentBase() expected_value1 = "TP1/Test_Task_1/Test_Task_1_Main_v001" expected_value2 = "TP2/Test_Task_1/Test_Task_1_Main_v001" # version1 native trimmed_path = env.trim_repo_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value1) # version2 native trimmed_path = env.trim_repo_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value2) # version1 windows trimmed_path = env.trim_repo_path("T:/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value1) # version2 windows trimmed_path = env.trim_repo_path("S:/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value2) # version1 linux trimmed_path = env.trim_repo_path("/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value1) # version2 linux trimmed_path = env.trim_repo_path("/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value2) # version1 osx trimmed_path = env.trim_repo_path("/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value1) # version2 osx trimmed_path = env.trim_repo_path("/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001") self.assertEqual(trimmed_path, expected_value2)
def test_get_version_from_full_path_with_multiple_repositories(self): """testing if the get version from full path is working fine with multiple repositories and with same version names """ repo1 = Repository(name='Test Repo 1', linux_path='/mnt/T/', windows_path='T:/', osx_path='/Volumes/T/') DBSession.add(repo1) repo2 = Repository(name='Test Repo 2', linux_path='/mnt/S/', windows_path='S:/', osx_path='/Volumes/S/') DBSession.add(repo2) task_ft = FilenameTemplate( name='Task Filename Template', target_entity_type='Task', path='$REPO{{project.repository.code}}/{{project.code}}/' '{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/{%- endfor -%}', filename='{{task.nice_name}}_{{version.take_name}}' '_v{{"%03d"|format(version.version_number)}}', ) DBSession.add(task_ft) structure1 = Structure(name='Commercial Project Structure', templates=[task_ft]) DBSession.add(structure1) status1 = Status(name='Status 1', code='STS1') status2 = Status(name='Status 2', code='STS2') status3 = Status(name='Status 3', code='STS3') DBSession.add_all([status1, status2, status3]) proj_status_list = \ StatusList.query.filter_by(target_entity_type='Project').first() task_status_list = \ StatusList.query.filter_by(target_entity_type='Task').first() version_status_list = StatusList(name='Version Statuses', target_entity_type='Version', statuses=[status1, status2, status3]) DBSession.add(version_status_list) project1 = Project(name='Test Project 1', code='TP1', repositories=[repo1], structure=structure1, status_list=proj_status_list) DBSession.add(project1) project2 = Project(name='Test Project 2', code='TP2', repositories=[repo2], structure=structure1, status_list=proj_status_list) DBSession.add(project2) task1 = Task(name='Test Task 1', code='TT1', project=project1, status_list=task_status_list) DBSession.add(task1) task2 = Task(name='Test Task 1', code='TT1', project=project2, status_list=task_status_list) DBSession.add(task2) DBSession.commit() # now create versions version1 = Version(task=task1, status_list=version_status_list) DBSession.add(version1) DBSession.commit() version1.update_paths() version2 = Version(task=task2, status_list=version_status_list) DBSession.add(version2) DBSession.commit() version2.update_paths() DBSession.commit() logger.debug('version1.full_path : %s' % version1.full_path) logger.debug('version2.full_path : %s' % version2.full_path) # now try to get the versions with an EnvironmentBase instance env = EnvironmentBase() # version1 version1_found = env.get_version_from_full_path( '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version1_found, version1) # version2 version2_found = env.get_version_from_full_path( '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version2_found, version2) # version1 in windows version1_found = env.get_version_from_full_path( 'T:/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version1_found, version1) # version2 in windows version2_found = env.get_version_from_full_path( 'S:/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version2_found, version2) # version1 in linux version1_found = env.get_version_from_full_path( '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version1_found, version1) # version2 in linux version2_found = env.get_version_from_full_path( '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version2_found, version2) # version1 in osx version1_found = env.get_version_from_full_path( '/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version1_found, version1) # version2 in osx version2_found = env.get_version_from_full_path( '/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(version2_found, version2)
def test_trim_repo_path_with_multiple_repositories(self): """testing if the trim_repo_path is working fine with multiple repositories and with same version names """ repo0 = Repository( name='Test Repo 0', linux_path='/mnt/T/with_a_very_long_path_which_will_cause_errors/', windows_path='T:/with_a_very_long_path_which_will_cause_errors/', osx_path='/Volumes/T/' 'with_a_very_long_path_which_will_cause_errors/') DBSession.add(repo0) repo1 = Repository(name='Test Repo 1', linux_path='/mnt/T/', windows_path='T:/', osx_path='/Volumes/T/') DBSession.add(repo1) repo2 = Repository(name='Test Repo 2', linux_path='/mnt/S/', windows_path='S:/', osx_path='/Volumes/S/') DBSession.add(repo2) task_ft = FilenameTemplate( name='Task Filename Template', target_entity_type='Task', path='{{project.code}}/{%- for parent_task in parent_tasks -%}' '{{parent_task.nice_name}}/{%- endfor -%}', filename='{{task.nice_name}}_{{version.take_name}}' '_v{{"%03d"|format(version.version_number)}}', ) DBSession.add(task_ft) structure1 = Structure(name='Commercial Project Structure', templates=[task_ft]) DBSession.add(structure1) status1 = Status(name='Status 1', code='STS1') status2 = Status(name='Status 2', code='STS2') status3 = Status(name='Status 3', code='STS3') DBSession.add_all([status1, status2, status3]) proj_status_list = \ StatusList.query.filter_by(target_entity_type='Project').first() task_status_list = \ StatusList.query.filter_by(target_entity_type='Task').first() DBSession.add(task_status_list) project1 = Project(name='Test Project 1', code='TP1', repositories=[repo1], structure=structure1, status_list=proj_status_list) DBSession.add(project1) project2 = Project(name='Test Project 2', code='TP2', repositories=[repo2], structure=structure1, status_list=proj_status_list) DBSession.add(project2) task1 = Task(name='Test Task 1', code='TT1', project=project1, status_list=task_status_list) DBSession.add(task1) task2 = Task(name='Test Task 1', code='TT1', project=project2, status_list=task_status_list) DBSession.add(task2) DBSession.commit() # now create versions version1 = Version(task=task1, status_list=version_status_list) DBSession.add(version1) DBSession.commit() version1.update_paths() version2 = Version(task=task1) DBSession.add(version2) DBSession.commit() version2.update_paths() version3 = Version(task=task2) DBSession.add(version3) DBSession.commit() version3.update_paths() version4 = Version(task=task2) DBSession.add(version4) DBSession.commit() version4.update_paths() DBSession.commit() logger.debug('version1.full_path : %s' % version1.full_path) logger.debug('version2.full_path : %s' % version2.full_path) logger.debug('version3.full_path : %s' % version2.full_path) logger.debug('version4.full_path : %s' % version2.full_path) # now try to get the versions with an EnvironmentBase instance env = EnvironmentBase() expected_value1 = 'TP1/Test_Task_1/Test_Task_1_Main_v001' expected_value2 = 'TP2/Test_Task_1/Test_Task_1_Main_v001' # version1 native trimmed_path = env.trim_repo_path( '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value1) # version2 native trimmed_path = env.trim_repo_path( '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value2) # version1 windows trimmed_path = env.trim_repo_path( 'T:/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value1) # version2 windows trimmed_path = env.trim_repo_path( 'S:/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value2) # version1 linux trimmed_path = env.trim_repo_path( '/mnt/T/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value1) # version2 linux trimmed_path = env.trim_repo_path( '/mnt/S/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value2) # version1 osx trimmed_path = env.trim_repo_path( '/Volumes/T/TP1/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value1) # version2 osx trimmed_path = env.trim_repo_path( '/Volumes/S/TP2/Test_Task_1/Test_Task_1_Main_v001') self.assertEqual(trimmed_path, expected_value2)
def create_render_job(self): """creates render job for the clip """ # create a new render output for each clip from anima.env import blackmagic resolve = blackmagic.get_resolve() pm = resolve.GetProjectManager() proj = pm.GetCurrentProject() template_name = "PlateInjector" result = proj.LoadRenderPreset(template_name) if not result: print("No template named: %s" % template_name) else: print("Template loaded successfully: %s" % template_name) # get the shot from stalker import Task, Shot, Type # shot = Shot.query.filter(Shot.project==self.project).filter(Shot.code==self.shot_code).first() # if not shot: # # raise RuntimeError("No shot with code: %s" % self.shot_code) shot = self.create_shot_hierarchy() # get plate task plate_type = Type.query.filter(Type.name == 'Plate').first() if not plate_type: raise RuntimeError("No plate type!!!") plate_task = Task.query.filter(Task.parent == shot).filter(Task.type == plate_type).first() if not plate_task: raise RuntimeError("No plate task in shot: %s" % self.shot_code) proj.SetCurrentRenderFormatAndCodec('exr', 'RGBHalfZIP') version = plate_task.versions[-1] from stalker import Version assert isinstance(version, Version) version = version.latest_version assert isinstance(version, Version) from anima.env.base import EnvironmentBase version_sig_name = EnvironmentBase.get_significant_name(version, include_project_code=False) extension = version.extension version.update_paths() version.extension = extension import os custom_name = '%s.' % version_sig_name target_dir = os.path.join( version.absolute_path, 'Outputs', version.take_name, 'v%03d' % version.version_number, 'exr' ) proj.SetRenderSettings({ 'MarkIn': self.clip.GetStart(), 'MarkOut': self.clip.GetEnd() - 1, 'CustomName': custom_name, 'TargetDir': target_dir }) # proj.SetCurrentRenderMode(1) proj.AddRenderJob()