def rollbackShotFilesGo(answer,versionedFolders,asset_name,toCheckout):
	if answer:
		version = int(answer[1:])	
		versionStr = "%03d" % version

		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):
			newLighting = os.path.join(versionedFolders, "v" + versionStr)

			# Again: set the latest version in the .nodeInfo file to the selected version, and checkout the next version.
			#asset_name, ext = os.path.splitext(filename)

			checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), (asset_name[0]+"_lighting"))

			oldVersion = int(amu.tempSetVersion(toCheckout, version))

			oldVersionStr = "%03d" % oldVersion				
			
			tempFilePath = os.path.join(checkoutFilePath + "_" + versionStr)
			filePath = os.path.join(checkoutFilePath + "_" + oldVersionStr)

			# Discard the old file, and check out the rollbacked one.
			amu.discard(filePath) # Hey! This is working!!!
			amu.checkout(toCheckout, True)
			
			# Then resetting the version number back to the most recent, so when we check in again, we will be in the most recent version.
			amu.tempSetVersion(toCheckout, oldVersion)
			correctCheckoutDest = amu.getCheckoutDest(toCheckout)
			#print "correctCheckoutDest ", correctCheckoutDest

			os.rename(tempFilePath, correctCheckoutDest)
Пример #2
0
def rollbackOTLgo(answer, versionedFolders, asset_name, toCheckout):
    #answer = dialog.answer#hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True)
    if answer:
        version = int(answer[1:])
        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, versionStr))
            oldVersionStr = "%03d" % oldVersion
            print toCheckout
            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)
def rollbackOTLgo(answer,versionedFolders,asset_name,toCheckout):
	#answer = dialog.answer#hou.ui.selectFromList(selections, message='Select version to rollback:', exclusive=True)
	if answer:
		version = int(answer[1:])
		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, versionStr))
			oldVersionStr = "%03d" % oldVersion
			print toCheckout
			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)
Пример #4
0
def rollbackShotFiles():
	# NOTE: Currently, we do not "check out" a shot file when it is pulled in. That is interesting. I wonder why not? Anyway, I don't know if that is an issue yet. Ah well. I guess we'll play with it.
	print "RollbackShotFiles"
	filepath = hou.hipFile.path() # The filepath goes to the path for the checked out file in the user directory.
	filename = os.path.basename(filepath)

	if not (filename == "untitled.hip"):\
		# If it isn't untitled, then we have a checked out lighting file, and we will proceed.
		shotNumber = filename.split("_");

		shotPaths = os.path.join(SHOTSDIR, str(shotNumber[0]))
		lightingPath = os.path.join(shotPaths, "lighting")
		lightingSrc = os.path.join(lightingPath, "src")		
		versions = glob.glob(os.path.join(lightingSrc, "*"))

		versionList = []
		for v in versions:
			versionList.append(os.path.basename(v))
		versionList.sort() # Should only be one. Whatever.

		answer = hou.ui.selectFromList(versionList, message='Select lighting version to rollback:', exclusive=True)
		if answer:		
			version = answer[0]
			versionStr = "%03d" % version

			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):
				newLighting = os.path.join(lightingSrc, "v" + versionStr)

				# Again: set the latest version in the .nodeInfo file to the selected version, and checkout the next version.
				asset_name, ext = os.path.splitext(filename)
				checkoutFilePath = os.path.join(amu.getUserCheckoutDir(), asset_name)

				oldVersion = int(amu.tempSetVersion(lightingPath, version))
				oldVersionStr = "%03d" % oldVersion				
				
				tempFilePath = os.path.join(checkoutFilePath + "_" + versionStr)
				filePath = os.path.join(checkoutFilePath + "_" + oldVersionStr)

				# Discard the old file, and check out the rollbacked one.
				amu.discard(filePath) # Hey! This is working!!!
				amu.checkout(lightingPath, True)
				
				# Then resetting the version number back to the most recent, so when we check in again, we will be in the most recent version.
				amu.tempSetVersion(lightingPath, oldVersion)
				correctCheckoutDest = amu.getCheckoutDest(lightingPath)
				print "correctCheckoutDest ", correctCheckoutDest

				os.rename(tempFilePath, correctCheckoutDest)
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)
Пример #6
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!')
Пример #7
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()
Пример #8
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()
Пример #9
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()
Пример #11
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)
Пример #12
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) 
Пример #13
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!')
Пример #14
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) 
Пример #15
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')
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)
Пример #17
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)
Пример #18
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()
Пример #19
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)
Пример #20
0
def rollbackShotFilesGo(answer, versionedFolders, asset_name, toCheckout):
    if answer:
        version = int(answer[1:])
        versionStr = "%03d" % version

        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):
            newLighting = os.path.join(versionedFolders, "v" + versionStr)

            # Again: set the latest version in the .nodeInfo file to the selected version, and checkout the next version.
            #asset_name, ext = os.path.splitext(filename)

            checkoutFilePath = os.path.join(amu.getUserCheckoutDir(),
                                            (asset_name[0] + "_lighting"))

            oldVersion = int(amu.tempSetVersion(toCheckout, version))

            oldVersionStr = "%03d" % oldVersion

            tempFilePath = os.path.join(checkoutFilePath + "_" + versionStr)
            filePath = os.path.join(checkoutFilePath + "_" + oldVersionStr)

            # Discard the old file, and check out the rollbacked one.
            amu.discard(filePath)  # Hey! This is working!!!
            amu.checkout(toCheckout, True)

            # Then resetting the version number back to the most recent, so when we check in again, we will be in the most recent version.
            amu.tempSetVersion(toCheckout, oldVersion)
            correctCheckoutDest = amu.getCheckoutDest(toCheckout)
            #print "correctCheckoutDest ", correctCheckoutDest

            os.rename(tempFilePath, correctCheckoutDest)
 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)
Пример #22
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)
Пример #23
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()
Пример #24
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()
Пример #25
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()
Пример #26
0
 def checkout(self):
     return amu.checkout(self.workingDirectory, True)
Пример #27
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"
Пример #28
0
 def checkout(self):
     return amu.checkout(self.workingDirectory, True)