def get_children(sid): sid = Sid(sid) # make certain it is a Sid search_sid = sid + '*' if search_sid == sid: warn('Can not get children on a final sid.') return [] return FS.get(search_sid)
def get(self, project, type, param1, param2, task, subtask): try: return get_paths( Sid(sid='/'.join( [project, type, param1, param2, task, subtask, "*", "*"]))) except Exception as ex: return {"data": [], "message": "Erreur : " + ex.message}
def post(self, project, type, param1, param2, task, subtask, version, state, ext): try: parser = reqparse.RequestParser() parser.add_argument('tag', required=False) parser.add_argument('comment', required=False) args = parser.parse_args() sid = Sid(sid='/'.join([ project, type, param1, param2, task, subtask, version, state, ext ])) entities.create_entity(sid, args['tag'], args['comment']) return {'message': "Success", 'data': True}, 201 except PipeException as ex: return {'message': str(ex.message), 'data': False}, 409 except Exception as ex: return {'message': str(ex.message), 'data': False}, 409
def get(search_sid): """ Finds Sids based on the given search Sid, using the Glob syntax. Returns a sorted, uniqued list :param search_sid: :return: result list """ search = Sid(search_sid) # filling intermediate values with * last_key = search.last_key() search = search.get_filled(by='*', until=last_key) debug('Search : ' + str(search)) info('PATH : {}'.format(search.path)) path = search.path if not path: warn('Search sid {} did not resolve to a path. Cancelled.'.format( search)) return [] debug('Search path : ' + str(path)) project = Sid(search.get('project')) # TODO need a way to find a root path depending on other sid parts (eg: fx caches) project_path = project.path pattern = path.split(project_path + '/')[-1] for key, value in six.iteritems(search_path_mapping): pattern = pattern.replace(key, value) debug('pattern : ' + str(pattern)) debug('project_path : ' + str(project_path)) if str(pattern) == str(project_path): warn('No valid search pattern') return [] """ found = [] for ext in pattern.split('.')[-1].split(','): new_pattern = pattern.split('.')[0] + '.' + ext found.extend(glob.glob(os.path.join(project_path, new_pattern))) """ found = glob.glob(os.path.join(project_path, pattern)) result = [] for path in found: path = str(path).replace(os.sep, '/') try: sid = Sid(path=path) except SpilException as e: debug('Path did not generate sid : {}'.format(path)) continue if not sid: warn('Path did not generate sid : {}'.format(path)) continue result.append(sid) result = sorted(list(set(result))) return result
@staticmethod def get_children(sid): sid = Sid(sid) # make certain it is a Sid search_sid = sid + '*' if search_sid == sid: warn('Can not get children on a final sid.') return [] return FS.get(search_sid) if __name__ == '__main__': import sys print('Most tests are in tests.fx') import pprint as pp sid = Sid('aral/s/*/*/*/*/*/*/*') pp.pprint(FS.get(sid)) sys.exit() sid = Sid('demo/s/s010/p010/*') pp.pprint(FS.get(sid)) sid = Sid('demo/s/*/*/*') pp.pprint(FS.get(sid)) sid = Sid('demo/s/./*') pp.pprint(FS.get(sid)) print FS.get(Sid('demo/s/./*')) == FS.get(Sid('demo/s/*')) # strange # produces errors : sid = Sid('demo/s/../*')
def get_engine_sid(self): """ Get the SID of the engine file open :return: SID of the engine file open """ return Sid(path=self.engine.get_file_path())
try: return self.datas.get(sid) except Exception as ex: raise ex def get_files_info(self, sid): """ Get date / tag / comment from a sid :param sid: sid to get info :return: date / tag / comment """ try: return self.datas.get_file_info(sid) except Exception as ex: raise ex if __name__ == '__main__': entities = Entities() shotSid = Sid( path= r"I:\SynologyDrive\ARAL\03_WORK_PIPE\02_SHOT\3d\scenes\s010\p010\fx\pyro\work_v010\s010_p010.ma" ) assetSid = Sid( path= r"I:\SynologyDrive\ARAL\03_WORK_PIPE\01_ASSET_3D\01_characters\dieu\3d\scenes\02_modelinglowres\maya\work_v004\dieu.ma" ) print str(shotSid) entities.make_new_version(shotSid, '', '')
def set_env_var(self, path): """ Workspace """ workspace_path = path.split('/scenes')[0] pnum = '' snum = '' name = '' if '02_SHOT' in path.split('/'): # FIXME: redo with sid. shot_path = path.split('02_SHOT')[0] + '02_SHOT/3d' asset_path = path.split('02_SHOT')[0] + '01_ASSET_3D' pnum = path.split('/')[8] snum = path.split('/')[7] wipcache_path = os.path.join( path.split('02_SHOT/3d/scenes')[0], '03_WIP_CACHE_FX', pnum, snum).replace(os.sep, '/') pubcache_path = os.path.join( path.split('02_SHOT/3d/scenes')[0], '04_PUBLISH_CACHE_FX', pnum, snum).replace(os.sep, '/') else: shot_path = path.split('01_ASSET_3D')[0] + '02_SHOT/3d' asset_path = path.split('01_ASSET_3D')[0] + '01_ASSET_3D' name = path.split('/')[6] wipcache_path = os.path.join( path.split('01_ASSET_3D')[0], '03_WIP_CACHE_FX', name).replace(os.sep, '/') pubcache_path = os.path.join( path.split('01_ASSET_3D')[0], '04_PUBLISH_CACHE_FX', name).replace(os.sep, '/') sid = Sid(path=path) if sid.is_shot(): farm = '{}_{}_{}'.format( sid.get('project').upper(), sid.get('seq'), sid.get('shot')) elif sid.is_asset(): farm = '{}_{}'.format(sid.get('project').upper(), sid.get('name')) project = sid.get_as('project').path images_out = os.path.dirname(sid.get_with(ext='exr').path) envs = { 'JOB': workspace_path, 'WIPCACHE': wipcache_path, 'PUBCACHE': pubcache_path, 'ASSET': asset_path, 'SHOT': shot_path, 'PNUM': pnum, # would call SHOT_PATH for path and SHOT for the shot 'SNUM': snum, 'ASSET_NAME': name, 'FARM': farm, 'PROJECT': project, 'SID': str(sid), 'IMAGES_OUT': images_out, } for key, value in envs.iteritems(): hou.hscript('setenv {}={}'.format(key, value)) log.debug('${} = {}'.format(key, value)) log.debug('Done set_env_var')