def configure_locations(event): '''Configure locations for session.''' session = event['data']['session'] # Find location(s) and customise instances. location = session.ensure('Location', {'name': 'test.location'}) ftrack_api.mixin( location, ftrack_api.entity.location.UnmanagedLocationMixin ) location.accessor = ftrack_api.accessor.disk.DiskAccessor(prefix='')
def configure_locations(event): '''Configure locations for session.''' session = event['data']['session'] location = session.query("Location where name is \"lucidity\"").one() location.accessor = ftrack_api.accessor.disk.DiskAccessor(prefix="") location.structure = Structure() location.priority = 50 ftrack_api.mixin(location, ftrack_api.entity.location.UnmanagedLocationMixin, name="Unmanaged")
def test_mixin(): '''Mixin class to instance.''' instance_a = Class() instance_b = Class() assert not hasattr(instance_a, 'method') assert not hasattr(instance_b, 'method') ftrack_api.mixin(instance_a, Mixin) assert hasattr(instance_a, 'method') assert instance_a.method() is True assert not hasattr(instance_b, 'method')
def configure_locations(event): '''Configure locations for session.''' session = event['data']['session'] # Find location(s) and customise instances. location = session.query('Location where name is "studio.remote"').one() ftrack_api.mixin(location, ftrack_api.entity.location.UnmanagedLocationMixin) bucket_name = os.getenv("FTRACK_S3_ACCESSOR_BUCKET", "ftrack") # Setup accessor to use bucket location.accessor = S3Accessor(bucket_name) location.structure = ftrack_api.structure.id.IdStructure() location.priority = 30
def test_mixin_same_class_multiple_times(): '''Mixin class to instance multiple times.''' instance = Class() assert not hasattr(instance, 'method') assert len(instance.__class__.mro()) == 2 ftrack_api.mixin(instance, Mixin) assert hasattr(instance, 'method') assert instance.method() is True assert len(instance.__class__.mro()) == 4 ftrack_api.mixin(instance, Mixin) assert hasattr(instance, 'method') assert instance.method() is True assert len(instance.__class__.mro()) == 4
task = session.get('Task', 'add1dbc2-fe0c-11e9-b582-0a58ac1e0254') #任务的父级用与以下发布资产 task_parent = task['parent'] #创建资产和该资产的版本 task_type = session.query('AssetType where name is "Geometry"').one() #创建一个资产 asset = session.create( 'Asset', { 'name': 'rndt_seq1_0010_comp_v079_ytj', 'type': task_type, 'parent': task_parent }) #创建一个版本 asset_version = session.create('AssetVersion', {'asset': asset, 'task': task}) location = session.query('Location where name is "rd2"').one() ftrack_api.mixin(location, ftrack_api.entity.location.UnmanagedLocationMixin) path = r'y:\rndtest_rndt\seq1\0010\comp\v006\fullres\rndt_seq1_0010_comp_v006_ytj.1005.exr' location.accessor = ftrack_api.accessor.disk.DiskAccessor(prefix=path) location.structure = ftrack_api.structure.origin.OriginStructure(prefix=r'') #拿到资源标识符 component_path = path #任务不用做资产的父级,把任务和assetversion直接连接 #当我们有一个可以创建组建得的版本 #这将自动创建一个新组件并将其添加到已配置为第一个优先级的位置 component_a = asset_version.create_component(component_path, data={'name': 'render'}, location=location) print component_a.get_availability() print location.get_filesystem_path(component_a) session.commit()