def test_time_log_creation_for_a_WFD_leaf_task(self): """testing if a StatusError will be raised when a TimeLog instance wanted to be created for a WFD leaf task """ new_task = Task(name='Test Task 2', project=self.test_project) new_task.depends = [self.test_task] self.kwargs['task'] = new_task self.assertRaises(StatusError, TimeLog, **self.kwargs)
def test_time_log_creation_for_a_WFD_leaf_task(self): """testing if a StatusError will be raised when a TimeLog instance wanted to be created for a WFD leaf task """ new_task = Task( name='Test Task 2', project=self.test_project ) new_task.depends = [self.test_task] self.kwargs['task'] = new_task self.assertRaises(StatusError, TimeLog, **self.kwargs)
def test_time_log_creation_for_a_WFD_leaf_task(self): """testing if a StatusError will be raised when a TimeLog instance wanted to be created for a WFD leaf task """ new_task = Task(name='Test Task 2', project=self.test_project) new_task.depends = [self.test_task1] kwargs = copy.copy(self.kwargs) kwargs['task'] = new_task with self.assertRaises(StatusError) as cm: TimeLog(**kwargs) self.assertEqual( str(cm.exception), 'Test Task 2 is a WFD task, and it is not allowed to create ' 'TimeLogs for a WFD task, please supply a RTS, WIP, HREV or DREV ' 'task!')
def test_time_log_creation_for_a_WFD_leaf_task(self): """testing if a StatusError will be raised when a TimeLog instance wanted to be created for a WFD leaf task """ from stalker import Task new_task = Task(name='Test Task 2', project=self.test_project) new_task.depends = [self.test_task1] kwargs = copy.copy(self.kwargs) kwargs['task'] = new_task from stalker.exceptions import StatusError with pytest.raises(StatusError) as cm: TimeLog(**kwargs) assert str(cm.value) == \ 'Test Task 2 is a WFD task, and it is not allowed to create ' \ 'TimeLogs for a WFD task, please supply a RTS, WIP, HREV or ' \ 'DREV task!'
print(wrong_shot) # should print None from stalker import Task previs = Task(name="Previs", parent=sh001) matchmove = Task(name="Matchmove", parent=sh001) anim = Task(name="Animation", parent=sh001) lighting = Task(name="Lighting", parent=sh001) comp = Task(name="comp", parent=sh001) comp.depends = [lighting] lighting.depends = [anim] anim.depends = [previs, matchmove] previs.resources = [me] previs.schedule_timing = 10 previs.schedule_unit = 'd' matchmove.resources = [me] matchmove.schedule_timing = 2 matchmove.schedule_unit = 'd' anim.resources = [me] anim.schedule_timing = 5 anim.schedule_unit = 'd'
anim = Task( name="Animation", parent=sh001 ) lighting = Task( name="Lighting", parent=sh001 ) comp = Task( name="comp", parent=sh001 ) comp.depends = [lighting] lighting.depends = [anim] anim.depends = [previs, matchmove] previs.resources = [me] previs.schedule_timing = 10 previs.schedule_unit = 'd' matchmove.resources = [me] matchmove.schedule_timing = 2 matchmove.schedule_unit = 'd' anim.resources = [me] anim.schedule_timing = 5 anim.schedule_unit = 'd'
def create_shot_hierarchy(self): """creates the related shot hierarchy """ logged_in_user = self.get_logged_in_user() from stalker import Task from stalker.db.session import DBSession shot = self.get_shot() if not shot: shot = self.create_shot() # creat shot tasks # Anim anim_task = Task.query.filter(Task.parent == shot).filter(Task.name == 'Anim').first() if not anim_task: anim_task = Task( name='Anim', parent=shot, type=self.get_type('Animation'), bid_timing=10, bid_unit='min', created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', ) DBSession.add(anim_task) # Camera camera_task = Task.query.filter(Task.parent == shot).filter(Task.name == 'Camera').first() if not camera_task: camera_task = Task( name='Camera', parent=shot, type=self.get_type('Camera'), bid_timing=10, bid_unit='min', created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', ) DBSession.add(camera_task) # Cleanup cleanup_task = Task.query.filter(Task.parent == shot).filter(Task.name == 'Cleanup').first() if not cleanup_task: cleanup_task = Task( name='Cleanup', parent=shot, type=self.get_type('Cleanup'), bid_timing=10, bid_unit='min', created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', ) DBSession.add(cleanup_task) # Comp comp_task = Task.query.filter(Task.parent == shot).filter(Task.name == 'Comp').first() if not comp_task: comp_task = Task( name='Comp', parent=shot, type=self.get_type('Comp'), bid_timing=10, bid_unit='min', created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', ) DBSession.add(comp_task) # Lighting lighting_task = Task.query.filter(Task.parent == shot).filter(Task.name == 'Lighting').first() if not lighting_task: lighting_task = Task( name='Lighting', parent=shot, type=self.get_type('Lighting'), bid_timing=10, bid_unit='min', created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', ) DBSession.add(lighting_task) # Plate plate_task = Task.query.filter(Task.parent == shot).filter(Task.name == 'Plate').first() if not plate_task: import datetime import pytz from stalker import defaults utc_now = datetime.datetime.now(pytz.utc) plate_task = Task( name='Plate', parent=shot, type=self.get_type('Plate'), schedule_timing=10, schedule_unit='min', schedule_model='duration', created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', start=utc_now, # this will be rounded to the timing resolution duration=defaults.timing_resolution ) DBSession.add(plate_task) # Create a dummy version if there is non from stalker import Version all_versions = Version.query.filter(Version.task == plate_task).all() if not all_versions: v = Version( task=plate_task, take_name='Main', # TODO: use the track name as take created_by=logged_in_user, updated_by=logged_in_user, description='Autocreated by Resolve', ) from anima.env import blackmagic resolve = blackmagic.get_resolve() version_info = resolve.GetVersion() v.created_with = 'Resolve%s.%s' % (version_info[0], version_info[1]) DBSession.add(v) # set the status the task with DBSession.no_autoflush: from stalker import Status cmpl = Status.query.filter(Status.code == 'CMPL').first() plate_task.status = cmpl # add dependency relation camera_task.depends = [plate_task] anim_task.depends = [camera_task] lighting_task.depends = [anim_task, camera_task] cleanup_task.depends = [plate_task] comp_task.depends = [lighting_task, cleanup_task] DBSession.commit() return shot