def test_file_type_filter(): ft = SQ.filter_fpt_by_name('maya_model_file', conn=conn) for f in ft: print("--------->", f.getName(), pformat(f)) dbc = DbCache() print(pformat(dbc.get_file_type_names()))
def test_db_asset_for_build_shot(): dbc = DbCache(shot_only=False, asset_only=True) showobj = dbc.get_showobj('dev_show') assert showobj != None M_SHADER_SF = 'maya_shader_src_file' M_RIG_SF = 'maya_rig_src_file' file_type_list = [M_SHADER_SF, M_RIG_SF] #,'maya_model_file'] #file_type_list = ['maya_rig_src_file'] #,'maya_model_file'] #pft_list = dbc.asset_maya_build_query(showobj, assetobj, file_type_list) fts = SQ.filter_fpt_by_name(file_type_list, conn=dbc.get_conn()) shd_src_pub_type = None rig_src_pub_type = None for f in fts: if f.getName() == M_RIG_SF: rig_src_pub_type = f elif f.getName() == M_SHADER_SF: shd_src_pub_type = f assert shd_src_pub_type != None assert rig_src_pub_type != None shot_list = dbc.load_shot('dev_show', ['007_0200', '051_0200']) assert len(shot_list) > 0 for shotobj in shot_list: print("SHOT", shotobj.code, shotobj.assets) assets_id = shotobj.get_asset_ids() assets_name = shotobj.get_asset_names() for as_id, as_name in zip(assets_id, assets_name): print("asset name:", as_name) ass = AssetInfoDb() ass.setName(as_name) ass.setdata(as_id) SW = StopWatch() SW.start() #pf_list = dbc.assetid_filepub_query(showobj, as_id, file_type_list) pf_list = dbc.assetid_filepubobj_query( showobj, ass, [rig_src_pub_type, shd_src_pub_type]) rig_srcs = pf_list[0] shd_srcs = pf_list[1] SW.stop() print("assetid_filepub_query in %f" % SW.elapsed()) """ much slower SW.start() a = dbc.assetid_filepub_query(showobj, as_id, [file_type_list[0]]) SW.stop() print("assetid_filepub_query1 in %f" % SW.elapsed()) SW.start() b = dbc.assetid_filepub_query(showobj, as_id, [file_type_list[1]]) SW.stop() print("assetid_filepub_query2 in %f" % SW.elapsed()) """ rig_mod_ids = [] rig_rig_ids = [] printinfo = True for pf in rig_srcs: if printinfo: print("VERSION RIG", pf.version_number) x = pf.get_upstream_model() if x != None: if printinfo: print("\tRIG model version", pf.get_upstream_model_version(), x['id']) rig_mod_ids.append(x['id']) x = pf.get_downstream_rig() if x: if printinfo: print("\tRIG rig version", pf.get_downstream_rig_version(), x['id']) rig_rig_ids.append(x['id']) shd_mod_ids = [] shd_cfx_ids = [] shd_shd_ids = [] for pf in shd_srcs: if printinfo: print("VERSION SHADER", pf.version_number) x = pf.get_upstream_model() if x != None: if printinfo: print("\tshader model version", pf.get_upstream_model_version(), x['id']) shd_mod_ids.append(x['id']) x = pf.get_upstream_cfx() if x != None: if printinfo: print("\tshader cfx version", pf.get_upstream_cfx_version(), x['id']) shd_cfx_ids.append(x['id']) x = pf.get_downstream_shader() if x != None: if printinfo: print("\tshader shader version", pf.get_downstream_shader_version(), x['id']) shd_shd_ids.append(x['id']) #print "shader model", shd_mod_ids #print "shader cfx", shd_cfx_ids #print "shader shader",shd_shd_ids #entity_publish_id = rig_mod_ids + rig_rig_ids + shd_mod_ids + shd_cfx_ids + shd_shd_ids # check cfx model version """ entity_publish_id = shd_cfx_ids if len(entity_publish_id) > 0: print("Q" * 100, entity_publish_id) res = ShotgunQuery.published_file_query(showobj.id, entity_publish_id , conn = dbc.get_conn()) print ("return res",res) for pf in res: x = pf.get_upstream_model() if x: print(x) print("\t\t\tfound model on cfx at version" % pf.get_upstream_model_version()) #print(pf.getName(),r.get_file_local_path()) """ """