Ejemplo n.º 1
0
    def checkout_version(self):
        dialogResult = self.verify_checkout_dialog()
        if(dialogResult == 'Yes'):
            #checkout
            version = str(self.current_item.text())[1:]
            filePath = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME)))
            toCheckout = amu.getCheckinDest(filePath)
            
            latestVersion = amu.tempSetVersion(toCheckout, version)
            amu.discard(filePath)
            try:
                destpath = amu.checkout(toCheckout, True)
            except Exception as e:
                if not amu.checkedOutByMe(toCheckout):
                    cmd.confirmDialog(  title          = 'Can Not Checkout'
                                   , message       = str(e)
                                   , button        = ['Ok']
                                   , defaultButton = 'Ok'
                                   , cancelButton  = 'Ok'
                                   , dismissString = 'Ok')
                    return
                else:
                    destpath = amu.getCheckoutDest(toCheckout)

            toOpen = os.path.join(destpath, self.get_filename(toCheckout)+'.mb')
            self.ORIGINAL_FILE_NAME = toOpen
            amu.tempSetVersion(toCheckout, latestVersion)
            if not os.path.exists(toOpen):
                # create new file
                cmd.file(force=True, new=True)
                cmd.file(rename=toOpen)
                cmd.file(save=True, force=True)
            self.close_dialog()
Ejemplo n.º 2
0
def checkout(node):
    """Checks out the selected node.  EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database."""
    if not isDigitalAsset(node):
        hou.ui.displayMessage("Not a Digital Asset.")
    else:
        if node.type().name() == "geometryTemplate":
            hou.ui.displayMessage("Cannot checkout geometry template node.")
            return False
        libraryPath = node.type().definition().libraryFilePath()
        filename = os.path.basename(libraryPath)

        asset_name, ext = os.path.splitext(filename)
        toCheckout = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'otl')
        myCheckout = False
        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            print str(e)
            myCheckout = amu.checkedOutByMe(toCheckout)
            if not myCheckout:
                # hou.ui.displayMessage('Can Not Checkout. Locked by')
                getInfo(node, 'Asset Locked')
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        if myCheckout:
            switchOPLibraries(os.path.join(OTLDIR, filename), os.path.join(destpath, filename))
        else:
            copyToUsrDir(node, filename, destpath)
        lockAsset(node, True)
        saveOTL(node)
        node.allowEditingOfContents()
        hou.ui.displayMessage("Checkout Successful!", title='Success!')
Ejemplo n.º 3
0
	def checkout_button_clicked(self):
		version = self.rollback_dialog.get_current_item()[1:]
		filePath = common.get_checkin_path()
		toCheckout = amu.getCheckinDest(filePath)
		
		latestVersion = amu.tempSetVersion(toCheckout, version)
		amu.discard(filePath)
		try:
			destpath = amu.checkout(toCheckout, True)
		except Exception as e:
			if not amu.checkedOutByMe(toCheckout):
				muke.message(str(e))
				return
			else:
				destpath = amu.getCheckoutDest(toCheckout)

		amu.tempSetVersion(toCheckout, latestVersion)
		# move to correct checkout directory
		correctCheckoutDir = amu.getCheckoutDest(toCheckout)
		if not destpath == correctCheckoutDir:
			if os.path.exists(correctCheckoutDir):
				shutil.rmtree(correctCheckoutDir)
			os.rename(destpath, correctCheckoutDir)
		toOpen = os.path.join(correctCheckoutDir, self.get_filename(toCheckout)+'.nk')
		if not os.path.exists(toOpen):
			# create new file
			nuke.scriptNew()
			nuke.scriptSaveAs(filename=toOpen, overwrite=0)
		else:
			nuke.scriptOpen(toOpen)
		self.rollback_dialog.close()
Ejemplo n.º 4
0
    def checkout_button_clicked(self):
        version = self.rollback_dialog.get_current_item()[1:]
        filePath = common.get_checkin_path()
        toCheckout = amu.getCheckinDest(filePath)

        latestVersion = amu.tempSetVersion(toCheckout, version)
        amu.discard(filePath)
        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                muke.message(str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        amu.tempSetVersion(toCheckout, latestVersion)
        # move to correct checkout directory
        correctCheckoutDir = amu.getCheckoutDest(toCheckout)
        if not destpath == correctCheckoutDir:
            if os.path.exists(correctCheckoutDir):
                shutil.rmtree(correctCheckoutDir)
            os.rename(destpath, correctCheckoutDir)
        toOpen = os.path.join(correctCheckoutDir,
                              self.get_filename(toCheckout) + '.nk')
        if not os.path.exists(toOpen):
            # create new file
            nuke.scriptNew()
            nuke.scriptSaveAs(filename=toOpen, overwrite=0)
        else:
            nuke.scriptOpen(toOpen)
        self.rollback_dialog.close()
	def checkout(self):
		curfilepath = cmd.file(query=True, sceneName=True)
		if not curfilepath == '':
			cmd.file(save=True, force=True)

		toCheckout = self.get_asset_path()

		try:
			destpath = amu.checkout(toCheckout, True)
		except Exception as e:
			print str(e)
			if not amu.checkedOutByMe(toCheckout):
				cmd.confirmDialog(  title          = 'Can Not Checkout'
                                   , message       = str(e)
                                   , button        = ['Ok']
                                   , defaultButton = 'Ok'
                                   , cancelButton  = 'Ok'
                                   , dismissString = 'Ok')
				return
			else:
				destpath = amu.getCheckoutDest(toCheckout)

		toOpen = os.path.join(destpath, self.get_filename(toCheckout)+'.mb')
		
		# open the file
		if os.path.exists(toOpen):
			cmd.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
		else:
			# create new file
			cmd.file(force=True, new=True)
			cmd.file(rename=toOpen)
			cmd.file(save=True, force=True)
		self.close_dialog()
Ejemplo n.º 6
0
def checkoutLightingFile():
    print("checkoutLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    print('Im calling ui')
    answer = ui.listWindow(selections, wmessage='Select shot file to checkout:')
    print('Im done calling ui')
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ['SHOTS_DIR'], selections[answer], 'lighting')

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                ui.infoWindow('Can Not Checkout: '+str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, get_filename(toCheckout)+'.hipnc')

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen) 
Ejemplo n.º 7
0
	def checkout(self):
		asset_name = self.checkout_dialog.get_current_item()
		toCheckout = os.path.join(os.environ['SHOTS_DIR'], asset_name,'compositing')
		#nuke.message(toCheckout)
		try:
			destpath = amu.checkout(toCheckout, True)
			#nuke.message(destpath)		
		except Exception as e:
			if not amu.checkedOutByMe(toCheckout):
				nuke.message(str(e))
				return
			else:
				destpath = amu.getCheckoutDest(toCheckout)
				#nuke.message("destpath = " + destpath)
		toOpen = os.path.join(destpath,self.get_filename(toCheckout)+'.nk')
		#nuke.message(toOpen)
		#nuke.message("toOpen = " + toOpen)
		#nuke.scriptClose()
		if not os.path.exists(toOpen):
			nuke.scriptClear()
			nuke.scriptSaveAs(filename=toOpen, overwrite=1)
		else:
			nuke.scriptClear()
			nuke.scriptOpen(toOpen)
		nuke.message('Checkout Successful')
Ejemplo n.º 8
0
    def checkout(self):
        curfilepath = cmd.file(query=True, sceneName=True)
        if not curfilepath == '':
            cmd.file(save=True, force=True)

        toCheckout = self.get_asset_path()

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            print str(e)
            if not amu.checkedOutByMe(toCheckout):
                cmd.confirmDialog(title='Can Not Checkout',
                                  message=str(e),
                                  button=['Ok'],
                                  defaultButton='Ok',
                                  cancelButton='Ok',
                                  dismissString='Ok')
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, self.get_filename(toCheckout) + '.mb')
        # open the file
        if os.path.exists(toOpen):
            cmd.file(toOpen, force=True,
                     open=True)  #, loadReferenceDepth="none")
        else:
            # create new file
            cmd.file(force=True, new=True)
            cmd.file(rename=toOpen)
            cmd.viewClipPlane('perspShape', ncp=0.01)
            cmd.file(save=True, force=True)

        self.close_dialog()
Ejemplo n.º 9
0
def go():
    filePath = cmds.file(q=True, sceneName=True)
    toCheckin = os.path.join(amu.getUserCheckoutDir(),
                             os.path.basename(os.path.dirname(filePath)))
    toCheckout = amu.getCheckinDest(toCheckin)
    maya_checkin.checkin()
    try:
        destpath = amu.checkout(toCheckout, True)
    except Exception as e:
        print str(e)
        if not amu.checkedOutByMe(toCheckout):
            cmd.confirmDialog(title='Can Not Checkout',
                              message=str(e),
                              button=['Ok'],
                              defaultButton='Ok',
                              cancelButton='Ok',
                              dismissString='Ok')
            return
        else:
            destpath = amu.getCheckoutDest(toCheckout)
    filename = os.path.basename(os.path.dirname(
        toCheckout)) + '_' + os.path.basename(toCheckout) + '.mb'
    toOpen = os.path.join(destpath, filename)
    # open the file
    if os.path.exists(toOpen):
        cmds.file(toOpen, force=True, open=True)  #, loadReferenceDepth="none")
    else:
        # create new file
        cmds.file(force=True, new=True)
        cmds.file(rename=toOpen)
        cmds.viewClipPlane('perspShape', ncp=0.01)
        cmds.file(save=True, force=True)
def checkout():
    toCheckout = self.get_asset_path()
    try:
        destpath = amu.checkout(toCheckout, True)
    except Exception as e:
        print str(e)
        if not amu.checkedOutByMe(toCheckout):
            cmd.confirmDialog(
                title="Can Not Checkout",
                message=str(e),
                button=["Ok"],
                defaultButton="Ok",
                cancelButton="Ok",
                dismissString="Ok",
            )
            return
        else:
            destpath = amu.getCheckoutDest(toCheckout)
    toOpen = os.path.join(
        destpath, os.path.basename(os.path.dirname(parentdir)) + "_" + os.path.basename(parentdir) + ".mb"
    )

    # open the file
    if os.path.exists(toOpen):
        cmd.file(toOpen, force=True, open=True)  # , loadReferenceDepth="none")
    else:
        # create new file
        cmd.file(force=True, new=True)
        cmd.file(rename=toOpen)
        cmd.viewClipPlane("perspShape", ncp=0.01)
        cmd.file(save=True, force=True)
Ejemplo n.º 11
0
def checkoutLightingFile():
    print("checkoutLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    answer = hou.ui.selectFromList(selections, message='Select shot file to checkout:', exclusive=True)
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ['SHOTS_DIR'], selections[answer], 'lighting')

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                hou.ui.displayMessage('Can Not Checkout: '+str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, get_filename(toCheckout)+'.hipnc')

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen) 
Ejemplo n.º 12
0
def checkout(node):
    """Checks out the selected node.  EXACTLY ONE node may be selected, and it MUST be a digital asset.
        The node must already exist in the database."""
    if not isDigitalAsset(node):
        hou.ui.displayMessage("Not a Digital Asset.")
    else:
        if node.type().name() == "geometryTemplate":
            hou.ui.displayMessage("Cannot checkout geometry template node.")
            return False
        libraryPath = node.type().definition().libraryFilePath()
        filename = os.path.basename(libraryPath)

        asset_name, ext = os.path.splitext(filename)
        toCheckout = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'otl')
        myCheckout = False
        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            print str(e)
            myCheckout = amu.checkedOutByMe(toCheckout)
            if not myCheckout:
                hou.ui.displayMessage('Can Not Checkout.')
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        if myCheckout:
            switchOPLibraries(os.path.join(OTLDIR, filename), os.path.join(destpath, filename))
        else:
            copyToUsrDir(node, filename, destpath)
        lockAsset(node, True)
        saveOTL(node)
        node.allowEditingOfContents()
        hou.ui.displayMessage("Checkout Successful!", title='Success!')
Ejemplo n.º 13
0
def checkoutLightingFile():
    print("checkoutLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ["SHOTS_DIR"], "*"))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    print("Im calling ui")
    answer = ui.listWindow(selections, wmessage="Select shot file to checkout:")
    print("Im done calling ui")
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ["SHOTS_DIR"], selections[answer], "lighting")

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                ui.infoWindow("Can Not Checkout: " + str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, get_filename(toCheckout) + ".hipnc")

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen)
def go():
    filePath = cmds.file(q=True, sceneName=True)
    toCheckin = os.path.join(amu.getUserCheckoutDir(), os.path.basename(os.path.dirname(filePath)))
    toCheckout = amu.getCheckinDest(toCheckin) 
    maya_checkin.checkin()
    try:
        destpath = amu.checkout(toCheckout, True)
    except Exception as e:
        print str(e)
        if not amu.checkedOutByMe(toCheckout):
            cmd.confirmDialog(  title          = 'Can Not Checkout'
                               , message       = str(e)
                               , button        = ['Ok']
                               , defaultButton = 'Ok'
                               , cancelButton  = 'Ok'
                               , dismissString = 'Ok')
            return
        else:
            destpath = amu.getCheckoutDest(toCheckout)
    filename = os.path.basename(os.path.dirname(toCheckout))+'_'+os.path.basename(toCheckout)+'.mb'
    toOpen = os.path.join(destpath, filename)
    # open the file
    if os.path.exists(toOpen):
        cmds.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
    else:
        # create new file
        cmds.file(force=True, new=True)
        cmds.file(rename=toOpen)
        cmds.viewClipPlane('perspShape', ncp=0.01)
        cmds.file(save=True, force=True)
Ejemplo n.º 15
0
def checkoutLightingFile():
    print("checkoutLightingFile")
    shotPaths = glob.glob(os.path.join(os.environ['SHOTS_DIR'], '*'))
    selections = []
    for sp in shotPaths:
        selections.append(os.path.basename(sp))
    selections.sort()
    answer = hou.ui.selectFromList(selections,
                                   message='Select shot file to checkout:',
                                   exclusive=True)
    if answer:
        answer = answer[0]
        toCheckout = os.path.join(os.environ['SHOTS_DIR'], selections[answer],
                                  'lighting')

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            if not amu.checkedOutByMe(toCheckout):
                hou.ui.displayMessage('Can Not Checkout: ' + str(e))
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath,
                              ham.get_filename(toCheckout) + '.hipnc')

        if os.path.exists(toOpen):
            hou.hipFile.load(toOpen)
        else:
            hou.hipFile.clear()
            hou.hipFile.save(toOpen)
Ejemplo n.º 16
0
def rollbackOTL(node=None):
    """Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset.
	    The node must already exist in the database.
	"""
    print 'RollbackOTL'

    #Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation.
    if node != None:

        if not ham.isDigitalAsset(node):
            ui.infoWindow('Wait! You can only rollback Digital Assets!')
            print "NOT A DIGITAL ASSET."
        else:
            # First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so.
            # For the productions path
            libraryPath = node.type().definition().libraryFilePath()
            filename = os.path.basename(libraryPath)

            asset_name, ext = os.path.splitext(filename)
            #print "asset_name " + asset_name
            toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl')
            #print "toCheckout " + toCheckout
            myCheckout = False

            myCheckout = amu.isCheckedOut(toCheckout)
            if myCheckout:  #If it has been checked out
                myCheckout = amu.checkedOutByMe(toCheckout)
                if myCheckout:  #If user was the last to checkout
                    #Here we rollback.
                    versionedFolders = os.path.join(toCheckout, "src")
                    #print "versionedFolders ", versionedFolders
                    versions = glob.glob(os.path.join(versionedFolders, '*'))
                    #print "selections ", versions
                    #Wooohoooo!!!
                    selections = []
                    selectionInfo = []
                    nodeInfoDest = toCheckout

                    for vr in versions:
                        selections.append(os.path.basename(vr))
                        comment = amu.getVersionComment(
                            nodeInfoDest, os.path.basename(vr))
                        selectionInfo.append(comment)
                    selections.sort()
                    dialog = VersionDialog()
                    dialog.addItems(selections, selectionInfo)
                    dialog.show()
                    dialog.setParams(versionedFolders, asset_name, toCheckout,
                                     True)
                    pyqt_houdini.exec_(dialog)

                else:
                    hou.ui.displayMessage('Already checked out.')
                    return
            else:
                hou.ui.displayMessage('Please checkout asset first.')
    else:
        print "Node does not exist"
def rollbackOTL(node = None):
	"""Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset.
	    The node must already exist in the database.
	"""
	print 'RollbackOTL'

	#Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation.
	if node != None:

		if not ham.isDigitalAsset(node):
			ui.infoWindow('Wait! You can only rollback Digital Assets!')
			print "NOT A DIGITAL ASSET."
		else:
			# First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so.
			# For the productions path			
			libraryPath = node.type().definition().libraryFilePath()
			filename = os.path.basename(libraryPath)

			asset_name, ext = os.path.splitext(filename)
			#print "asset_name " + asset_name
			toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl')
			#print "toCheckout " + toCheckout
			myCheckout = False

			myCheckout = amu.isCheckedOut(toCheckout)
			if myCheckout: #If it has been checked out
				myCheckout = amu.checkedOutByMe(toCheckout)
				if myCheckout: #If user was the last to checkout
					#Here we rollback.
					versionedFolders = os.path.join(toCheckout, "src")
					#print "versionedFolders ", versionedFolders
					versions = glob.glob(os.path.join(versionedFolders, '*'))
					#print "selections ", versions
					#Wooohoooo!!!
					selections = []
					selectionInfo = []
					nodeInfoDest = toCheckout

					for vr in versions:
						selections.append(os.path.basename(vr))
						comment = amu.getVersionComment(nodeInfoDest,os.path.basename(vr))
						selectionInfo.append(comment)
					selections.sort()
					dialog = VersionDialog()
					dialog.addItems(selections,selectionInfo)
					dialog.show()
					dialog.setParams(versionedFolders,asset_name,toCheckout,True)
					pyqt_houdini.exec_(dialog)
					
				else:
					hou.ui.displayMessage('Already checked out.')
					return
			else:
				hou.ui.displayMessage('Please checkout asset first.')
	else:
		print "Node does not exist"
 def checkout(self):
     asset_name = str(self.current_item.text())
     toCheckout = os.path.join(os.environ["SHOTS_DIR"], asset_name, "compositing")
     try:
         destpath = amu.checkout(toCheckout, True)
     except Exception as e:
         if not amu.checkedOutByMe(toCheckout):
             nuke.message(str(e))
             return
         else:
             destpath = amu.getCheckoutDest(toCheckout)
     toOpen = os.path.join(destpath, self.get_filename(toCheckout) + ".nk")
     if os.path.exists(toOpen):
         nuke.scriptOpen(toOpen)
         nuke.message("Checkout Successful")
         self.close()
     else:
         nuke.message("No File Found" + toOpen)
Ejemplo n.º 19
0
    def checkout(self):
        curfilepath = cmd.file(query=True, sceneName=True)
        if not curfilepath == '':
            cmd.file(save=True, force=True)

        asset_name = str(self.current_item.text())
        if self.model_radio.isChecked():
            toCheckout = os.path.join(os.environ['ASSETS_DIR'], asset_name,
                                      'model')
        elif self.rig_radio.isChecked():
            toCheckout = os.path.join(os.environ['ASSETS_DIR'], asset_name,
                                      'rig')
        elif self.animation_radio.isChecked():
            toCheckout = os.path.join(os.environ['SHOTS_DIR'], asset_name,
                                      'animation')

        try:
            destpath = amu.checkout(toCheckout, True)
        except Exception as e:
            print str(e)
            if not amu.checkedOutByMe(toCheckout):
                cmd.confirmDialog(title='Can Not Checkout',
                                  message=str(e),
                                  button=['Ok'],
                                  defaultButton='Ok',
                                  cancelButton='Ok',
                                  dismissString='Ok')
                return
            else:
                destpath = amu.getCheckoutDest(toCheckout)

        toOpen = os.path.join(destpath, self.get_filename(toCheckout) + '.mb')

        # open the file
        if os.path.exists(toOpen):
            cmd.file(toOpen, force=True,
                     open=True)  #, loadReferenceDepth="none")
        else:
            # create new file
            cmd.file(force=True, new=True)
            cmd.file(rename=toOpen)
            cmd.file(save=True, force=True)
        self.close_dialog()
Ejemplo n.º 20
0
    def checkout_version(self):
        dialogResult = self.verify_checkout_dialog()
        if (dialogResult == 'Yes'):
            #checkout
            version = str(self.current_item.text())[1:]
            filePath = os.path.join(
                amu.getUserCheckoutDir(),
                os.path.basename(os.path.dirname(self.ORIGINAL_FILE_NAME)))
            toCheckout = amu.getCheckinDest(filePath)

            latestVersion = amu.tempSetVersion(toCheckout, version)
            amu.discard(filePath)
            try:
                destpath = amu.checkout(toCheckout, True)
            except Exception as e:
                if not amu.checkedOutByMe(toCheckout):
                    cmd.confirmDialog(title='Can Not Checkout',
                                      message=str(e),
                                      button=['Ok'],
                                      defaultButton='Ok',
                                      cancelButton='Ok',
                                      dismissString='Ok')
                    return
                else:
                    destpath = amu.getCheckoutDest(toCheckout)

            amu.tempSetVersion(toCheckout, latestVersion)
            # move to correct checkout directory
            correctCheckoutDir = amu.getCheckoutDest(toCheckout)
            if not destpath == correctCheckoutDir:
                if os.path.exists(correctCheckoutDir):
                    shutil.rmtree(correctCheckoutDir)
                os.rename(destpath, correctCheckoutDir)
            toOpen = os.path.join(correctCheckoutDir,
                                  self.get_filename(toCheckout) + '.mb')
            self.ORIGINAL_FILE_NAME = toOpen
            if not os.path.exists(toOpen):
                # create new file
                cmd.file(force=True, new=True)
                cmd.file(rename=toOpen)
                cmd.file(save=True, force=True)
            cmd.file(self.ORIGINAL_FILE_NAME, force=True, open=True)
            self.close_dialog()
Ejemplo n.º 21
0
 def checkout(self):
     asset_name = str(self.current_item.text())
     toCheckout = os.path.join(os.environ['SHOTS_DIR'], asset_name,
                               'compositing')
     try:
         destpath = amu.checkout(toCheckout, True)
     except Exception as e:
         if not amu.checkedOutByMe(toCheckout):
             nuke.message(str(e))
             return
         else:
             destpath = amu.getCheckoutDest(toCheckout)
     toOpen = os.path.join(destpath, self.get_filename(toCheckout) + '.nk')
     if os.path.exists(toOpen):
         nuke.scriptOpen(toOpen)
         nuke.message('Checkout Successful')
         self.close()
     else:
         nuke.message('No File Found' + toOpen)
Ejemplo n.º 22
0
	def checkout(self):
		curfilepath = cmd.file(query=True, sceneName=True)
		if not curfilepath == '':
			cmd.file(save=True, force=True)

		asset_name = str(self.current_item.text())
		if self.model_radio.isChecked():
			toCheckout = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'model')
		elif self.rig_radio.isChecked():
			toCheckout = os.path.join(os.environ['ASSETS_DIR'], asset_name, 'rig')
		elif self.animation_radio.isChecked():
			toCheckout = os.path.join(os.environ['SHOTS_DIR'], asset_name, 'animation')

		try:
			destpath = amu.checkout(toCheckout, True)
		except Exception as e:
			print str(e)
			if not amu.checkedOutByMe(toCheckout):
				cmd.confirmDialog(  title          = 'Can Not Checkout'
                                   , message       = str(e)
                                   , button        = ['Ok']
                                   , defaultButton = 'Ok'
                                   , cancelButton  = 'Ok'
                                   , dismissString = 'Ok')
				return
			else:
				destpath = amu.getCheckoutDest(toCheckout)

		toOpen = os.path.join(destpath, self.get_filename(toCheckout)+'.mb')
		
		# open the file
		if os.path.exists(toOpen):
			cmd.file(toOpen, force=True, open=True)#, loadReferenceDepth="none")
		else:
			# create new file
			cmd.file(force=True, new=True)
			cmd.file(rename=toOpen)
			cmd.file(save=True, force=True)
		self.close_dialog()
Ejemplo n.º 23
0
def rollbackOTL(node = None):
	"""Pulls a rollback window for the user to select a version to rollback to. EXACTLY ONE node may be selected, and it MUST be a digital asset.
	    The node must already exist in the database.
	"""
	print 'RollbackOTL'

	ham.updateDB()

	#Need to check if a particular node is a digital asset first. Rollback is will only work as a DA, with model, rigs and animation.
	if node != None:

		if not ham.isDigitalAsset(node):
			ui.infoWindow('Wait! You can only rollback Digital Assets!')
			print "NOT A DIGITAL ASSET."
		else:
			# First, we need to see if this is checked out or not. If it is checked out, then we can proceed. If not, state so.
			# For the productions path			
			libraryPath = node.type().definition().libraryFilePath()
			filename = os.path.basename(libraryPath)

			asset_name, ext = os.path.splitext(filename)
			#print "asset_name " + asset_name
			toCheckout = os.path.join(ASSETSDIR, asset_name, 'otl')
			#print "toCheckout " + toCheckout
			myCheckout = False

			myCheckout = amu.isCheckedOut(toCheckout)
			if myCheckout: #If it has been checked out
				myCheckout = amu.checkedOutByMe(toCheckout)
				if myCheckout: #If user was the last to checkout
					#Here we rollback.
					versionedFolders = os.path.join(toCheckout, "src")
					#print "versionedFolders ", versionedFolders
					versions = glob.glob(os.path.join(versionedFolders, '*'))
					#print "selections ", versions
					#Wooohoooo!!!
					selections = []
					for vr in versions:
						selections.append(os.path.basename(vr))
					selections.sort()
					answer = hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True)
					if answer:
						version = answer[0]
						versionStr = "%03d" % version

						newVersion = os.path.join(versionedFolders, "v" + versionStr)
						checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name)


						rollingBack = hou.ui.displayMessage('WARNING: You are about to remove your most recent changes. Proceed at your own risk.', buttons=('Actually, I don\'t want to', 'Yes. Roll me back'), severity=hou.severityType.Warning, title=("Woah there, pardner!"))
						

						if (rollingBack):
							print "rollingBack"
							# Temporarily set the version to the rollback version, and check out.
							oldVersion = int(amu.tempSetVersion(toCheckout, version))
							oldVersionStr = "%03d" % oldVersion

							tempFilePath = os.path.join(checkoutFilePath + "_otl_" + versionStr)
							filePath = os.path.join(checkoutFilePath + "_otl_" + oldVersionStr)
							# Now that we've set the version, we will 
							amu.discard(filePath) # Hey! This is working!!!
							amu.checkout(toCheckout, True)

							# Reset the version number, and rename the checkout path to the most recent version.
							amu.tempSetVersion(toCheckout, oldVersion)
							correctCheckoutDest = amu.getCheckoutDest(toCheckout)
							os.rename(tempFilePath, correctCheckoutDest)
				else:
					hou.ui.displayMessage('Already checked out.')
					return
			else:
				hou.ui.displayMessage('Please checkout asset first.')				


			
	else:
		print "Node does not exist"
Ejemplo n.º 24
0
 def checkedOutByMe(self):
     return amu.checkedOutByMe(self.workingDirectory)
Ejemplo n.º 25
0
 def checkedOutByMe(self):
     return amu.checkedOutByMe(self.workingDirectory)