def run(): import sys from spil.libs.util.log import setLevel, DEBUG, INFO print('') print('Tests start') print('') setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode print('*' * 60) test_paths = [] # tests = [r'Z:\Projects\Vic_Movie\Prod'] # if not input('Create if not existing ?'): # sys.exit() from spil.conf.sid_conf import test_sids as tests test_sids = [] for test in tests: sid = Sid(test) print('Sid : {}'.format(sid)) # We fill defaults, and strip sid.set_defaults() print('Sid with defaults: {}'.format(sid)) sid = sid.get_stripped() print('Sid stripped: {}'.format(sid)) path = sid.path if path: test_paths.append(path) print('Appended : {}'.format(path)) print('') for path in test_paths: path = Path(path) print(path) if not path.exists(): if is_filename(path): print(path, 'is a file') if not path.parent.exists(): os.makedirs(str(path.parent)) path.touch() else: print(path, 'is a dir') os.makedirs(str(path)) print('Created test paths : ') pprint(test_paths)
def run(): from spil.libs.util.log import setLevel, DEBUG, INFO, warn setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode print('') print('Tests start - Please init files for this to work') print('') from spil.conf.sid_conf import test_sids asset_sid = test_sids[0] sid = Sid(asset_sid) print(sid) print('') print('Get all characters (children of cat)') for asset in FS.get_children(sid.get_as('cat')): print(asset) print('') print('Get all tasks (children of asset name)') for asset in FS.get_children(sid.get_as('name')): print(asset) print('') print('Get by search sid : all tasks') search_sid = sid.get_with(name='*', task='*', cat='*').get_as('task') for asset in FS.get(search_sid): print(asset) print('') print('Get by search sid : all tasks for the given asset') search_sid = sid.get_with(task='*', cat='*').get_as('task') for asset in FS.get(search_sid): print(asset) print('') print('Get by search sid : all assets of cat "fx" in project demo') search_sid = Sid('demo/a/fx/*') for asset in FS.get(search_sid): print(asset) print('') print('Get by search sid : all "shots" in project demo') search_sid = Sid('demo/s/*/*') for sid in FS.get(search_sid): print(sid) print('') print('Get by search sid : all "seq" in project demo') search_sid = Sid('demo/s/*') for sid in FS.get(search_sid): print(sid) print('')
def all_open_projects(self): result = [] for project in gazu.project.all_open_projects(): project_sid_name = project_mapping['project'].get(project.get('name')) sid = Sid(project_sid_name) if not sid: print('Project {} is not conform - skipped'.format(project_sid_name)) continue sid.conform() result.append(sid) return sorted(result)
def by_sids(tests): for test in tests: info('Testing : {}'.format(test)) info('') test = Sid(test) _dict = test.asdict() _type = test.sidtype() info('Initial sid dict : {}'.format(_dict)) info('Initial sid basetype : {}'.format(_type)) path = None try: path = dict_to_path(_dict) info('Resolved to path : {}'.format(path)) except SpilException as e: info('Unable to resolve path because : {}'.format(e)) test = test.parent(set_default=True) # we try to level one up if test: info('Sid up one level (parent)...') warn('Sid is now : {}'.format(test)) _dict = test.asdict() _type = test.sidtype() info('Sid dict is now : {}'.format(_dict)) path = dict_to_path( test.asdict()) # do not catch error if this doesnt work info('Resolved to path : {}'.format(path)) _type, retour = path_to_dict(path) if _type: info('Retour resolved') else: info('No match.') continue info('Resolved retour dict : {}'.format(retour)) info('') # assert (_dict == retour) # dicts do not need to be identical. retour = Sid(data=retour) info('Retour sid : {}'.format(retour)) info('') warn('test ' + str(test)) warn('test ' + str(retour)) assert (test == retour) info('') info('*' * 30) info('')
def all_shots_for_project(self, project_name): project_name = fs_conf.path_mapping["project"][project_name] sid = Sid(project_name + '/s') sids = [] project = gazu.project.get_project_by_name(get_key_project(project_name)) shots = gazu.shot.all_shots_for_project(project) for shot in shots: shot_sid = sid.copy() shot_sid.shot = shot.get('name') shot_sid.seq = gazu.shot.get_sequence(shot.get('parent_id')).get('name') shot_sid.conform() sids.append(shot_sid) return sorted(sids)
def get_sid(self): """ Get the sid of the current file """ path = self.get_file_path() cur_sid = Sid(path=path) if not cur_sid: warnings.warn("sid of the current maya scene is not valid") return cur_sid
def all_assets_for_project(self, project_name): project_name = fs_conf.path_mapping["project"][project_name] sid = Sid(project_name + '/a') sids = [] project = gazu.project.get_project_by_name(get_key_project(project_name)) assets = gazu.asset.all_assets_for_project(project) for asset in assets: asset_sid = sid.copy() asset_sid.name = asset.get('name') asset_sid.cat = gazu.asset.get_asset_type(asset.get('entity_type_id')).get('name') # Fix cat FS / CGW for cat_fs in FS.get_children(asset_sid.get_as('project')): if str(asset_sid.get('cat')).lower() in cat_fs.get('cat'): asset_sid.set('cat', cat_fs) asset_sid.conform() sids.append(asset_sid) return sorted(sids)
print('') print('Tests start') print('') setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode from spil.conf.sid_conf import test_sids as tests test_sids = [] for test in tests: print('Testing : {}'.format(test)) print('') sid = Sid(test) pprint(sid) assert (eval(repr(sid)) == sid) assert (test == str(sid)) print('') pprint(sid.asdict()) print('') pprint(get_members(sid)) print('') print('*' * 30) print('') test_sids.append(sid) print('') print('*' * 30) print('')
def set_status(self, sidParam, code_status, comment): sid = Sid(sidParam) # handling the incoming sid or string # FIXME Mapping #sid = Sid(sid.project + '/s') task_status = '' if sid.is_shot(): shotName = sid.shot # TO Delete # shotName = "sh01" projectNameCGWire = "" for key in project_mapping["project"]: if (project_mapping["project"].get(key) == sid.project): projectNameCGWire = key project = gazu.project.get_project_by_name(projectNameCGWire) shots = gazu.shot.all_shots_for_project(project) shotFound = [] for shot in shots: #print (shot) if(shot.get('name').lower() == shotName): shotFound = shot tasks = gazu.task.all_tasks_for_shot(shotFound) task = '' for t in tasks: #print (t) if(t.get('task_type_name').lower() == sid.task.lower()): task = t #print (t.get('task_status_name')) # print("Tasks status") # pprint(gazu.task.get_task_status(task)) task_status = gazu.task.get_task_status(task) gazu.task.add_comment(task, gazu.task.get_task_status_by_short_name(code_status), comment) elif sid.is_asset(): assetName = sid.name # TO delete!!!! # assetName = "test_character_1" projectNameCGWire = "" # print("sid.task :") # print(sid.task) for key in project_mapping["project"]: if (project_mapping["project"].get(key) == sid.project): projectNameCGWire = key project = gazu.project.get_project_by_name(projectNameCGWire) assets = gazu.asset.all_assets_for_project(project) assetFound = [] for asset in assets: # print (asset) if(asset.get('name').lower() == assetName): assetFound = asset tasks = gazu.task.all_tasks_for_asset(assetFound) task = '' for t in tasks: # print (t) # print(t.get('task_type_name').lower() + " "+ sid.task.lower()) if(t.get('task_type_name').lower() == sid.task.lower()): task = t # print (t.get('task_status_name')) # print("Tasks status : ") # pprint(gazu.task.get_task_status(task)) task_status = gazu.task.get_task_status(task) gazu.task.add_comment(task, gazu.task.get_task_status_by_short_name(code_status), comment) else: print("Error!!") pass
def get_status(self, sidParam): sid = Sid(sidParam) # handling the incoming sid or string # FIXME Mapping #sid = Sid(sid.project + '/s') task_status = '' if sid.is_shot(): shotName = sid.shot projectNameCGWire = "" for key in project_mapping["project"]: if (project_mapping["project"].get(key) == sid.project): projectNameCGWire = key project = gazu.project.get_project_by_name(projectNameCGWire) shots = gazu.shot.all_shots_for_project(project) shotFound = [] for shot in shots: if(shot.get('name').lower() == shotName): shotFound = shot tasks = gazu.task.all_tasks_for_shot(shotFound) task = '' for t in tasks: #print (t) if(t.get('task_type_name').lower() == sid.task.lower()): task = t #print (t.get('task_status_name')) #print("Tasks status") pprint(gazu.task.get_task_status(task)) task_status = gazu.task.get_task_status(task) return task_status['short_name'] elif sid.is_asset(): assetName = sid.name print 'asset name : ' + assetName # TO delete!!!! # assetName = "crab" projectNameCGWire = "" #print("sid.task :") #print(sid.task) for key in project_mapping["project"]: if (project_mapping["project"].get(key) == sid.project): projectNameCGWire = key project = gazu.project.get_project_by_name(projectNameCGWire) assets = gazu.asset.all_assets_for_project(project) assetFound = [] for asset in assets: #print (asset) if(asset.get('name').lower() == assetName): assetFound = asset print "ASSET FOUND : " + str(assetFound) tasks = gazu.task.all_tasks_for_asset(assetFound) task = '' for t in tasks: # print (t) # print(t.get('task_type_name').lower() + " "+ sid.task.lower()) if(t.get('task_type_name').lower() == sid.task.lower()): task = t #print (t.get('task_status_name')) #print("Tasks status : ") #pprint(gazu.task.get_task_status(task)) task_status = gazu.task.get_task_status(task) return task_status['short_name'] else: return task_status
def get_all_status(self, sidParam): sid = Sid(sidParam) # handling the incoming sid or string # FIXME Mapping #sid = Sid(sid.project + '/s') tasksAll = [] if sid.is_shot(): print ("Sid : " + sid.shot) print (sid.get_as("shot")) print ("Project : " + sid.project) shotName = sid.shot projectNameCGWire = "" for key in project_mapping["project"]: if (project_mapping["project"].get(key) == sid.project): projectNameCGWire = key print("nameCGWire : " + projectNameCGWire) #project = gazu.project.get_project_by_name(project_mapping["project"].get(projectNameCGWire)) project = gazu.project.get_project_by_name(projectNameCGWire) #print (project) shots = gazu.shot.all_shots_for_project(project) for shot in shots: # print ('') # print ("Get : " + shot.get('name') + " Name : " + shotName) # if(shot.get('name') == shotName): if(shot.get('name') == "SH01"): shot_sid = sid.copy() shot_sid.shot = shot.get('name') tasksAll = gazu.task.all_tasks_for_shot(shot) # shot_sid.seq = gazu.shot.get_sequence(shot.get('parent_id')).get('name') # shot_sid.conform() # print ("Shot : " + shot_sid.shot + " " + "Seq : " + shot_sid.seq) # sids.append(shot_sid) return tasksAll elif sid.is_asset(): print ("Sid : " + sid.task) print (sid.get_as("asset")) print ("Project : " + sid.project) assetName = sid.name projectNameCGWire = "" for key in project_mapping["project"]: if (project_mapping["project"].get(key) == sid.project): projectNameCGWire = key print("nameCGWire : " + projectNameCGWire) #project = gazu.project.get_project_by_name(project_mapping["project"].get(projectNameCGWire)) project = gazu.project.get_project_by_name(projectNameCGWire) #print (project) assets = gazu.asset.all_assets_for_project(project) for asset in assets: print ('') print ("Get : " + asset.get('name')) # if(shot.get('name') == assetName): if(asset.get('name') == "test_character_1"): asset_sid = sid.copy() asset_sid.shot = asset.get('name') tasksAll = gazu.task.all_tasks_for_asset(asset) print for t in tasksAll: print (t) # shot_sid.seq = gazu.shot.get_sequence(shot.get('parent_id')).get('name') # shot_sid.conform() # print ("Shot : " + shot_sid.shot + " " + "Seq : " + shot_sid.seq) # sids.append(shot_sid) return tasksAll else: return tasksAll
# print("Tasks status : ") # pprint(gazu.task.get_task_status(task)) task_status = gazu.task.get_task_status(task) gazu.task.add_comment(task, gazu.task.get_task_status_by_short_name(code_status), comment) else: print("Error!!") pass if __name__ == '__main__': from pprint import pprint from pipeline.libs.utils.log import setLevel, INFO, DEBUG sid = Sid('demo/a/01_characters/crab') setLevel(INFO) cgw = CgWire() for asset in cgw.all_for_project("aral"): print str(asset) """ # cahier des charges final # sid = Sid('demo/a/characters/test_character_1/concept') print cgw.get_status(str(sid)) cgw.set_status(sid, 'wfa', 'cool!') pprint(cgw.all_open_projects())
info('') info('Tests start') info('') setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode from spil.conf.fs_conf import test_paths as tests test_paths = [] for test in tests: info('Testing : {}'.format(test)) info('') sid = Sid(path=test) if not sid: info('Not matching, skipping : {}'.format(test)) continue info('Resolved {}'.format(sid)) retour = sid.path info('Retour path : {}'.format(retour)) assert (test == retour) info('') info('*' * 30) info('') test_paths.append(test)
from spil.libs.util.log import setLevel, DEBUG, INFO, info info('') info('Tests start') info('') setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode from spil.conf.sid_conf import test_sids as tests for test in tests: info('Testing : {}'.format(test)) info('') sid = Sid(test) if not sid: info('Sid not correct, skipping : {}'.format(test)) continue if sid.sidtype() in ['shot_version', 'asset_version']: # FIXME : explicit conf info( 'This type cannot be resolved to a path : {}. Skipped'.format( sid.sidtype())) continue path = sid.path info('Resolved path {}'.format(path)) retour = Sid(path=path)
if __name__ == '__main__': from spil.libs.util.log import setLevel, DEBUG, INFO, info info('') info('Search Tests start') info('') setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode from spil.conf.fs_conf import search_sids for test in search_sids[0:]: search = Sid(test) if not search: info('Search not matching a sid, skipping : {}'.format(test)) continue info('Search : {} ({})'.format(search, search.sidtype())) for sid in FS.get(search): # info('{} ({})'.format(sid, sid.sidtype())) info('\t\tFound {}'.format(sid)) info(' ' * 10) info('*' * 20)
def run(): from spil.libs.util.log import setLevel, DEBUG, INFO, warn setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode print('') print('Tests start') print('') from spil.conf.sid_conf import test_sids asset_sid = test_sids[0] sid = Sid(asset_sid) print(sid) print('Acess to "values"') if sid.is_asset: print(sid.get('cat')) print(sid.get('name')) elif sid.is_shot: print(sid.get('seq')) print(sid.get('shot')) print(sid.get('version')) print(sid.get('task')) print(sid.path) print('') print('Changing the Sid') print(sid.get_as('task')) print(sid.get_as('task').parent()) print(sid.get_with('task', 'surfacing')) print(sid.get_with(task='setup', state='w')) print('') print('Utilities') print(sid.get_as('subtask').parent().last_key()) # 'task' # sid until name does not have a task print(sid.get_as('name').has_a('task')) print(len(sid)) # the number of valid values print(len(sid.get_as('task'))) print('') print('Iterating over keys - always all the keys') for key in sid.keys: print('\t' + key) print('') print('Iterate over values - only valid (or optional) values') for value in sid.get_as('task'): print('\t' + value) print('') print('Types & dict') print(sid.sidtype()) print(sid.basetype()) print(sid.endtype()) print(sid.asdict()) print('')
if __name__ == '__main__': from spil.libs.util.log import setLevel, DEBUG, INFO, info info('') info('Search Tests start') info('') setLevel(INFO) # setLevel(DEBUG) # In case of problems, use DEBUG mode from spil.conf.sid_conf import test_sids for test in test_sids[0:]: sid = Sid(test).get_with('subtask', '*') # FIXME info('Sid : {}'.format(sid)) for sid in FS.get_children(sid): # info('{} ({})'.format(sid, sid.sidtype())) info('\t\tChild {}'.format(sid)) search = Sid(test).get_with('task', '*').get_with( 'state', '*').get_with('version', '*').get_with('subtask', '*') if not search: info('Search not matching a sid, skipping : {}'.format(test)) continue info('Search : {} ({})'.format(search, search.sidtype()))
self.create_package_file(sid.get_as('state'), value) # CREATE WORKSPACE self.create_asset_workspace(sid) return sid # endregion if __name__ == '__main__': from spil.libs.sid import Sid sid_test = Sid( path= "I:/SynologyDrive/ARAL/03_WORK_PIPE/01_ASSET_3D/01_characters/dummy/3d/scenes/01_modeling/maya/work_v001" ) # Get print('SID : ' + str(sid_test)) print('get_files : ' + str(FileSystem.get_files(sid_test))) print('get_extension : ' + FileSystem.get_extension(sid_test)) print('get_tag : ' + FileSystem.get_tag(sid_test)) print('get_date : ' + FileSystem.get_date(sid_test)) print('get_size : ' + FileSystem.get_size(sid_test)) print('get_next_version : ' + str(FileSystem.get_next_version(sid_test))) # File create FileSystem.create_txt_file(sid_test, "Write test") FileSystem.create_tag_file(sid_test, "tag test") shotSid = Sid( path=
from spil.libs.sid import Sid from spil.libs.util.log import setLevel, INFO, info, debug from spil.conf.sid_conf import test_sids if __name__ == '__main__': setLevel(INFO) #setLevel(DEBUG) # In case of problems, use DEBUG mode sid = Sid('demo/s/010/0200/animation/*/001/w/ma') print((sid + 'bla')) sid = Sid('demo/s/010/0200/layout/*/002/p') print(sid) sid = Sid('demo/s/010/0200') print(sid + 'layout' + '*' + '002' + 'p') debug('Tests are in the tests.sid_tests module') sids = test_sids for sid in sids: # sids[-1:]: info('') info('Testing {}'.format(sid)) info('') sid = Sid(sid) if sid.basetype() == 'project': continue if sid.is_shot(): info('Copy until Shot: {}'.format(sid.copy(until='shot')))