def __init__(self): self.host = '192.168.0.220' self.user = bs_pathGenerator.bs_getEnv()['projectShort'] # self.user = '******' self.password = '******' self.database = bs_pathGenerator.bs_getEnv()['projectName'] # self.database = 'kicko_speedo' self.dtConn = pymysql.connect(host=self.host, user=self.user, password=self.password, db=self.database) self.dtCur = self.dtConn.cursor()
def __init__(self, parent=None): super(Bs_AssetPublish, self).__init__(parent) # get environments. self.projectType = bs_pathGenerator.bs_getEnv()['projectType'] self.setupUi(self) self.connections() self.bsap_publish_pb.clicked.connect(self.publishAsset) self.addItemInTable() self.bsap_prevVers_tableWidget.resizeColumnsToContents() self.bsap_refresh_pb.clicked.connect(self.addItemInTable) # hide episode fields if environment is movie. if not self.projectType == 'series': self.bsap_episode_lbl.hide() self.bsap_episodeTag_lbl.hide()
def __init__(self, parent=None): super(Bs_AssetCreate, self).__init__(parent) # get environments. self.projectType = bs_pathGenerator.bs_getEnv()['projectType'] self.setupUi(self) # add restrictions in ui. self.bsag_epNumber_LE.setValidator( QtGui.QIntValidator(self.bsag_epNumber_LE)) self.bsag_epNumber_LE.setMaxLength(3) self.bsag_ep_LE.setReadOnly(True) # hide episode fields if environment is movie. if not self.projectType == 'series': self.bsag_epNumber_LE.hide() self.bsag_ep_LE.hide() self.label_3.hide() # add crete command in button. self.bsag_createAsset_pb.clicked.connect(self.connections)
def bs_createTextureBase(assetName, assetGrade, assetType, episode=None): """ @ create Texture Base group in reference model file in rig. Args: assetName (str): Model Name. assetGrade (str): Character Grade (Primary, Secondary, Tertiary). assetType (str): Asset Type Character, Prop, Set, Vehicle episode (str): asset Name dodo is like (dod). Returns: top Texture group. """ # raise popup window for current scene will be discarded if maya is not in batch mode. if not pm.about(batch=True): confirmation = pm.windows.confirmDialog( title='Confirm', message="Don't Save Current Scene\nAnd Load New Scene?", button=['Yes', 'No'], defaultButton='Yes') if confirmation == 'Yes': pm.newFile(f=True) else: print 'process cancelled', return False # get environments. serverPath = bs_pathGenerator.bs_getEnv()['projectDir'] # get model directory. if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': modelFile = bs_pathGenerator.bs_getOnlyFinalFileOfDept(assetType, 'Model', assetName, episode=episode) else: modelFile = bs_pathGenerator.bs_getOnlyFinalFileOfDept( assetType, 'Model', assetName) # create path using environment variable. modelFile = modelFile.replace(serverPath, '$BSW_PROJECT_DIR') bs_reference.bs_createReference(modelFile, prefixStyle='withoutNamespace', prefixName='') # create Texture Group. topGrp = pm.createNode('transform', n='Texture_Group', ss=True) # add asset uid. astTypShortCode = { 'Character': 'ch', 'Prop': 'pr', 'Set': 'bg', 'Vehicle': 'vh', 'SetElement': 'se' } if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': uid = 'bsw_' + astTypShortCode[ assetType] + '_' + assetName + '_tex_' + episode else: uid = 'bsw_' + astTypShortCode[assetType] + '_' + assetName + '_tex' # add attributes. pm.addAttr(topGrp, ln='assetBase', dt='string', k=True) pm.addAttr(topGrp, ln='assetType', dt='string', k=True) pm.addAttr(topGrp, ln='assetName', dt='string', k=True) pm.addAttr(topGrp, ln='assetGrade', dt='string', k=True) if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': pm.addAttr(topGrp, ln='assetEpisode', dt='string', k=True) pm.addAttr(topGrp, ln='assetUID', dt='string', k=True) # set Values. pm.setAttr(topGrp + '.assetBase', 'Asset') pm.setAttr(topGrp + '.assetBase', l=True) pm.setAttr(topGrp + '.assetType', assetType) pm.setAttr(topGrp + '.assetType', l=True) pm.setAttr(topGrp + '.assetName', assetName) pm.setAttr(topGrp + '.assetName', l=True) pm.setAttr(topGrp + '.assetGrade', assetGrade) pm.setAttr(topGrp + '.assetGrade', l=True) if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': pm.setAttr(topGrp + '.assetEpisode', episode) pm.setAttr(topGrp + '.assetEpisode', l=True) pm.setAttr(topGrp + '.assetUID', uid) pm.setAttr(topGrp + '.assetUID', l=True) # parent referenced model top group in texture group. pm.parent('geo', topGrp) if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': bs_pathGenerator.bs_createAssetDirectories(assetType, assetName, episode=episode) else: bs_pathGenerator.bs_createAssetDirectories(assetType, assetName) bs_qui.bs_displayMessage( 'success', 'asset Created success and created sourceimages directory') return topGrp
def bs_createModelBase(topGroup, assetName, assetGrade, assetType, episode=None, makeGroups=True): """ @ create asset model @ make modeling base hierarchy and add attributes on top group for query purpose. Args: topGroup (str): Hierarchy Top Group Name. assetName (str): Asset Name. assetGrade (str): Character Grade (Primary, Secondary, Tertiary). assetType (str): Asset Type Character, Prop, Set, Vehicle. episode (str): episode number like (ep000,ep001,ep002) format. makeGroups (bool): make groups if value is True Returns: topGrp. """ # raise popup window for current scene will be discarded if maya is not in batch mode. if not pm.about(batch=True): confirmation = pm.windows.confirmDialog( title='Confirm', message="Don't Save Current Scene\nAnd Load New Scene?", button=['Yes', 'No'], defaultButton='Yes') if confirmation == 'Yes': pm.newFile(f=True) else: print 'process cancelled', return False # create group if make hierarchy is True. astTypShortCode = { 'Character': 'ch', 'Prop': 'pr', 'Set': 'bg', 'Vehicle': 'vh', 'SetElement': 'se' } if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': uid = 'bsw_' + astTypShortCode[ assetType] + '_' + assetName + '_mod_' + episode else: uid = 'bsw_' + astTypShortCode[assetType] + '_' + assetName + '_mod' pm.select(cl=True) if makeGroups: # make groups. topGrp = pm.createNode('transform', n=topGroup, ss=True) modelGrp = pm.createNode('transform', n=assetName + '_grp', ss=True) if assetType == 'Character': bodyGrp = pm.createNode('transform', n='body_grp', ss=True) eyeGrp = pm.createNode('transform', n='eye_grp', ss=True) eyeBrowGrp = pm.createNode('transform', n='eyeBrow_grp', ss=True) innerMouthGrp = pm.createNode('transform', n='innerMouth_grp', ss=True) hairGrp = pm.createNode('transform', n='hair_grp', ss=True) clothGrp = pm.createNode('transform', n='cloth_grp', ss=True) propsGrp = pm.createNode('transform', n='props_grp', ss=True) shoeGrp = pm.createNode('transform', n='shoe_grp', ss=True) # make parent. pm.parent(bodyGrp, clothGrp, propsGrp, shoeGrp, modelGrp) pm.parent(eyeGrp, eyeBrowGrp, innerMouthGrp, hairGrp, bodyGrp) elif assetType == 'Set': setElementGrp = pm.createNode('transform', n='setElements_grp') pm.parent(modelGrp, setElementGrp, topGrp) pm.parent(modelGrp, topGrp) else: topGrp = topGroup # add attributes for query asset details purpose. pm.addAttr(topGrp, ln='assetBase', dt='string', k=True) pm.addAttr(topGrp, ln='assetType', dt='string', k=True) pm.addAttr(topGrp, ln='assetName', dt='string', k=True) pm.addAttr(topGrp, ln='assetGrade', dt='string', k=True) if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': pm.addAttr(topGrp, ln='assetEpisode', dt='string', k=True) pm.addAttr(topGrp, ln='assetUID', dt='string', k=True) # add asset details in top group attributes. pm.setAttr(topGrp + '.assetBase', 'Asset') pm.setAttr(topGrp + '.assetBase', l=True) pm.setAttr(topGrp + '.assetType', assetType) pm.setAttr(topGrp + '.assetType', l=True) pm.setAttr(topGrp + '.assetName', assetName) pm.setAttr(topGrp + '.assetName', l=True) pm.setAttr(topGrp + '.assetGrade', assetGrade) pm.setAttr(topGrp + '.assetGrade', l=True) if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': pm.setAttr(topGrp + '.assetEpisode', episode) pm.setAttr(topGrp + '.assetEpisode', l=True) pm.setAttr(topGrp + '.assetUID', uid) pm.setAttr(topGrp + '.assetUID', l=True) pm.select(topGrp, r=True) if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': bs_pathGenerator.bs_createAssetDirectories(assetType, assetName, episode=episode) else: bs_pathGenerator.bs_createAssetDirectories(assetType, assetName) bs_qui.bs_displayMessage('success', 'Asset Created Successfully....') return topGrp
def bs_publishCurrentAsset(comment=None): """ @ publish current opened asset. Args: comment (str): comment on publish. Returns: mainFilePath And versionFilePath. """ # get environments. projectType = bs_pathGenerator.bs_getEnv()['projectType'] assetDept, assetType, assetName, uid, episode = bs_pathGenerator.bs_getAssetDetails( ) if assetDept == 'Not Exist' or assetType == 'Not Exist' or assetName == 'Not Exist' or uid == 'Not Exist': bs_qui.bs_displayMessage('error', 'Asset not found To Publish.....') return False # get asset directories and create directories if not exist. if projectType == 'series': mainDir = bs_pathGenerator.bs_getAssetDeptDirs( assetType, assetName, episode=episode)[assetDept] verDir = bs_pathGenerator.bs_getAssetDeptDirs( assetType, assetName, episode=episode)[assetDept + 'Version'] bs_pathGenerator.bs_createAssetDirectories(assetType, assetName, episode=episode) else: mainDir = bs_pathGenerator.bs_getAssetDeptDirs(assetType, assetName)[assetDept] verDir = bs_pathGenerator.bs_getAssetDeptDirs( assetType, assetName)[assetDept + 'Version'] bs_pathGenerator.bs_createAssetDirectories(assetType, assetName) # get file paths to save the file. mainFilePath = mainDir + bs_pathGenerator.bs_getCurrentAssetMainFileName() versionFileName = bs_pathGenerator.bs_versionUpPath(verDir) # create new version file name if no version exist. if not versionFileName: versionFileName = bs_pathGenerator.bs_getCurrentAssetMainFileName( )[:-3] + '_v001.ma' versionFilePath = verDir + versionFileName # save version File. pm.saveAs(versionFilePath) # copy main version file and save as main File if fail then save manually. try: shutil.copy2(versionFilePath, mainFilePath) except: pm.saveAs(mainFilePath) # get version screenshot. imageFilePath = verDir + 'screenshot/' + versionFileName[:-3] + '.jpg' bs_screenshot.bs_getScreenShot(imageFilePath) # copy screenshot for main file. try: shutil.copy2(imageFilePath, imageFilePath[:-9] + '.jpg') except: pass # add entry in database. try: tableName = str(mainFilePath.split('/')[-1][:-3]) # mainFile entries. mainFileName = str(mainFilePath.split('/')[-1]) mainFileOwner = bs_os.bs_getFileOwner(mainFilePath) mainFileSize = bs_os.bs_getFileSize(mainFilePath) mainFileTime = bs_os.bs_getFileDateTime(mainFilePath) addInfoDB = bs_database.Bs_Database() addInfoDB.bs_databaseAssetPublish(tableName, mainFileName, mainFileOwner, mainFileSize, mainFileTime, comment) # version File entries. verFileName = str(versionFilePath.split('/')[-1]) verFileOwner = bs_os.bs_getFileOwner(mainFilePath) verFileSize = bs_os.bs_getFileSize(mainFilePath) verFileTime = bs_os.bs_getFileDateTime(mainFilePath) addInfoDB = bs_database.Bs_Database() addInfoDB.bs_databaseAssetPublish(tableName, verFileName, verFileOwner, verFileSize, verFileTime, comment) # print message. bs_qui.bs_displayMessage('success', 'Asset Publish Successfully...') except: bs_qui.bs_displayMessage( 'success', 'Asset Publish Successfully... But database is not not connected') return mainFilePath, versionFilePath
def projectType(self): if bs_pathGenerator.bs_getEnv()['projectType'] == 'series': return 'series' else: return None