def stage_workspace(task, name=None, template=None): '''Stage workspace for creation''' path_template = api.get_path_template('workspace') path = path_template.format(dict(task=task.path, workspace=name)) name = name return dict( name=name, path=path, tags=['workspace'], template=api.get_template(template, 'workspace'), ) @task(priority=types.VALIDATE) @requires(success('stage_workspace')) @params(store('workspace_item')) def validate_workspace(workspace_item): '''Validate potential workspace''' if os.path.exists(workspace_item['path']): raise Abort('Task already exists: ' + workspace_item['name']) return True @task(priority=types.COMMIT) @requires(success('validate_workspace')) @params(store('workspace_item')) @returns(artifact('workspace')) def commit_workspace(workspace_item): '''Create new workspace'''
@pass_kwargs @returns(store('task_item')) def stage_task(parent, type, name=None, template=None): '''Stage task for creation''' name = name or type return dict( name=name, path=unipath(parent.path, name), tags=['task', type], template=api.get_template(template, 'task'), ) @task(priority=types.VALIDATE) @requires(success('stage_task')) @params(store('task_item')) def validate_task(task_item): '''Validate potential task''' if os.path.exists(task_item['path']): raise Abort('Task already exists: ' + task_item['name']) return True @task(priority=types.COMMIT) @requires(success('validate_task')) @params(store('task_item')) @returns(artifact('task')) def commit_task(task_item): '''Create new task'''
try: template = api.get_template(template, 'collection') except KeyError: template = None return dict( name=name, path=collection_path, tags=['collection'], template=template, ) @task(priority=types.VALIDATE) @requires(success('stage_collection')) @params(store('collection_item')) def validate_collection(collection_item): '''Make sure new collection does not exist''' if os.path.exists(collection_item['path']): raise Abort('collection already exists: ' + collection_item['name']) return True @task(priority=types.COMMIT) @requires(success('validate_collection')) @params(store('collection_item')) @returns(artifact('collection')) def commit_collection(collection_item):
path=action.path, args=list(action.args) + list(args), name=action.name, env=dict(action.env), cwd=entry.path, host=action.host, task=ctx.task, workspace=ctx.workspace, default_workspace=action.default_workspace, ) return app @task(priority=SETUP_LAUNCH) @pass_context @requires(success('setup_app')) @params(store('app')) @available(lambda ctx: ctx.task and not ctx.workspace) @returns(artifact('workspace')) def setup_workspace(ctx, app): '''Setup a workspace for the current task''' workspace = app.task.workspaces.name(app.host).one() if not workspace and not app.default_workspace: raise Disable('Could not find workspace for %s' % app.host) artifact = False if not workspace: path_template = api.get_path_template('workspace') template = api.get_template(app.default_workspace, 'workspace')
subprocess.Popen(cmd, **kwargs) @task @params(kwarg('modules')) @returns(store('cpenv_modules')) def validate_cpenv_modules(modules): '''Validate cpenv modules''' import cpenv modules = modules.split() return cpenv.resolve(modules) @task @requires(success('validate_cpenv_modules')) @params(kwarg('root'), store('cpenv_modules')) @returns(artifact('cpenv_file')) def write_cpenv_modules(root, modules): '''Write a cpenv file to root''' resolver_str = ' '.join([m.qual_name for m in modules]) cpenv_file = os.path.join(root.path, '.cpenv').replace('\\', '/') with open(cpenv_file, 'w') as f: f.write(resolver_str) return cpenv_file @task @params(kwarg('root')) @returns(store('cpenv_modules'))
pass_context, returns, artifact, store, params, success, requires, ) from construct import types, get_host, utils from construct_launcher.constants import BEFORE_LAUNCH # Before launch task @task(priority=BEFORE_LAUNCH) @requires(success('build_app_env')) @params(store('app')) def setup_construct_maya(app): '''Setup Maya environment.''' userSetup = os.path.join(os.path.dirname(__file__), 'userSetup') scpath = os.pathsep.join([userSetup, app.env.get('MAYA_SCRIPT_PATH', '')]) pypath = os.pathsep.join([ userSetup, app.env.get('PYTHONPATH', ''), os.path.join(os.path.dirname(__file__), '..') ]) app.env['MAYA_SCRIPT_PATH'] = scpath app.env['PYTHONPATH'] = pypath
try: template = api.get_template(template, 'sequence') except KeyError: template = None return dict( name=name, path=sequence_path, tags=['sequence'], template=template, ) @task(priority=types.VALIDATE) @requires(success('stage_sequence')) @params(store('sequence_item')) def validate_sequence(sequence_item): '''Make sure new sequence does not exist.''' if os.path.exists(sequence_item['path']): raise Abort('Sequence already exists: ' + sequence_item['name']) return True @task(priority=types.COMMIT) @requires(success('validate_sequence')) @params(store('sequence_item')) @returns(artifact('sequence')) def commit_sequence(sequence_item): '''Make new sequence'''
try: template = api.get_template(template, 'shot') except KeyError: template = None return dict( name=name, path=shot_path, tags=['shot'], template=template, ) @task(priority=types.VALIDATE) @requires(success('stage_shot')) @params(store('shot_item')) def validate_shot(shot_item): '''Make sure shot does not exist''' if os.path.exists(shot_item['path']): raise Abort('Shot already exists: ' + shot_item['name']) return True @task(priority=types.COMMIT) @requires(success('validate_shot')) @params(store('shot_item')) @returns(artifact('shot')) def commit_shot(shot_item): '''Create new shot'''
# -*- coding: utf-8 -*- from __future__ import absolute_import, print_function __all__ = [ 'setup_construct_hou', ] import os from construct.utils import unipath from construct.tasks import (task, requires, success, params, store) @task @requires(success('build_app_env')) @params(store('app')) def setup_construct_hou(app): '''Setup Houdini environment''' hou_path = unipath(os.path.dirname(__file__), 'startup') old_hou_path = app.env.get('HOUDINI_PATH', None) if old_hou_path: hou_path += os.pathsep + old_hou_path old_pypath = app.env.get('PYTHONPATH', None) pypath = os.pathsep.join( [hou_path, os.path.join(os.path.dirname(__file__), '..')]) if old_pypath: pypath += os.pathsep + old_pypath app.env['HOUDINI_PATH'] = hou_path + os.pathsep + '&' app.env['PYTHONPATH'] = pypath
@task(priority=types.STAGE) @pass_kwargs @returns(store('project_item')) def stage_project(root, template): '''Stage project data for validation''' return dict(path=unipath(root), name=os.path.basename(root), template=api.get_template(template)) @task(priority=types.VALIDATE) @params(store('project_item')) @requires(success('stage_project')) def validate_project(project_item): '''Make sure the project does not already exist.''' if os.path.exists(project_item['path']): raise Abort('Project already exists: %s' % project_item['path']) return True @task(priority=types.COMMIT) @params(store('project_item')) @requires(success('validate_project')) @returns(artifact('project')) def commit_project(project_item): '''Copy the project template to project directory'''
def stage_asset_type(project, collection, name): '''Stage new asset_type Entry''' path_template = api.get_path_template('asset_type') asset_type_path = path_template.format( dict( project=project.path, collection=collection, asset_type=name, )) return fsfs.get_entry(asset_type_path) @task(priority=types.VALIDATE) @requires(success('stage_asset_type')) @params(store('asset_type')) def validate_asset_type(asset_type): '''Make sure new asset_type does not already exist''' if asset_type.exists: raise Abort('Asset Type already exists: %s' % asset_type.name) return True @task(priority=types.COMMIT) @requires(success('validate_asset_type')) @params(store('asset_type')) @returns(artifact('asset_type')) def commit_asset_type(asset_type): '''Commit new asset_type Entry'''
'''Stage template data''' templates_path = unipath(ctx.project.data.path, 'templates') template_path = unipath(templates_path, name) template_item = types.Namespace( entry=entry, name=name, path=template_path, include_files=include_files, ) return template_item @task(priority=types.VALIDATE) @requires(success('stage_template_data')) @params(store('template')) def validate_template(template): '''Make sure template does not already exist''' if (os.path.exists(template.path) or template.name in construct.get_templates()): raise Abort('Template already exists: ' + template.name) @task(priority=types.COMMIT) @requires(success('validate_template')) @params(store('template')) @returns(artifact('template')) def commit_template(template): '''Commit template'''
@returns(store('file')) def build_filename(workspace, name, version, ext): '''Builds the full save path''' task = workspace.parent() path_template = get_path_template('workspace_file') filename = path_template.format( dict(task=task.short, name=name, version='{:0>3d}'.format(version), ext=ext)) return utils.unipath(workspace.path, filename) @task @requires(success('build_filename')) @params(store('file')) def save_file(file): '''Save file in Host application''' host = get_host() host.save_file(file) class Open(Action): '''Open a file''' label = 'Open' identifier = 'file.open' parameters = dict( file={