Пример #1
0
def nk_rv(nodes=None):
	"""
	Send to RV
	SS Shift+r
	"""
	f_image = lambda node: os.path.join(nuke.actualFilename(n)[0],nuke.actualFilename(n)[-1])
	
	path = {}
	path['Write'] = f_image
	path['Read'] = f_image
	path['Precomp'] = lambda node: nuke.filename(node)
	
	inbox_rv = []
	inbox_nuke = []
	
	send_to = {}
	send_to['Read'] = inbox_rv
	send_to['Write'] = inbox_rv
	send_to['Precomp'] = inbox_nuke
	
	n = [send_to[n.Class()].append(path[n.Class()](n)) for n in nuke.selectedNodes() if n.Class() in path.keys()]

	[Popen("""nuke --nukex %s""" % p, stdout=PIPE, shell=True) for p in inbox_nuke]
	
	rv_cmd = {}
	rv_cmd[0] = lambda n: None
	rv_cmd[1] = lambda n: """%s -fullscreen "%s" """ % (os.environ['RVPATH'], n[0])
	rv_cmd[2] = lambda n: """%s -fullscreen -sessionType stack %s """ % ( os.environ['RVPATH']," ".join(n) )

	cmd = rv_cmd.get(len(inbox_rv), rv_cmd[2])(inbox_rv)
	if cmd: Popen(cmd, stdout=PIPE, shell=True)
Пример #2
0
	def run():
		for (i,node) in enumerate(readingNodes):
			if 'checksums' not in node.knobs().keys():
				tKnob = nuke.Text_Knob('checksums','checksums')
				tKnob.setVisible(False)
				node.addKnob(tKnob)
			(dirPath, basename, filename) = nuke.actualFilename(node)
			filepath = os.path.join(dirPath, filename)
			if os.path.exists(filepath):
				crc = hashlib.sha1(open(filepath).read(10485760)).hexdigest()
				node['checksums'].setValue(crc)
			task.setProgress(int(i*1./len(readingNodes)*100))
Пример #3
0
def reconnectMissing(indexCmd):
	# On Windows, use Everything (http://www.voidtools.com/).
	# Assumes "es.exe" command line program is in PATH. Note that
	# "es.exe" doesn't work with networked drives.
	# On OS X, use Spotlight.
	errors = [n for n in nuke._allNodes() if n.hasError() and nuke.filename(n) is not None]
	if errors:
		task = nuke.ProgressTask("Missing files!")
		task.setMessage("Reconnecting %i nodes" % len(errors))
		checkLog = False
		for (i,node) in enumerate(errors):
			(dirPath, basename, searchStr) = nuke.actualFilename(node)
			print "Reconnecting %s --> %s" % (node.name(), searchStr)
			results = [l.strip() for l in os.popen("""%s "%s" """ % (indexCmd,searchStr)).readlines()]
			def getNewPath(resultLine):
				(newPath, newBase) = os.path.split(resultLine)
				setPath = re.sub("\\\\","/",newPath) + "/" + basename
				return setPath
			if len(results)==1:
				node['file'].setValue(getNewPath(results[0]))
			elif len(results)>1:
				checkLog = True
				if 'checksums' in node.knobs().keys():
					crc = node['checksums'].value()
					checksums = [hashlib.sha1(open(f).read(10485760)).hexdigest() for f in results]
					if crc in checksums:
						res = results[checksums.index(crc)]
						node['file'].setValue(getNewPath(res))
					else:
						msg = "%s: CRC mismatch with found files" % node.name()
						print "-"*40 + "\n" + msg
						for (i,line) in enumerate(results): print "[%i] %s" % (i,line)
				else:
					node['file'].setValue(getNewPath(results[0]))
					msg = "More than 1 file found for %s:" % node.name()
					print "-"*40 + "\n" + msg
					for (i,line) in enumerate(results): print "[%i] %s" % (i,line)
			else:
				print "Reconnection failed. No files found."
			task.setProgress(int(i*1./len(errors)*100))
		if checkLog:
			msg = "More than 1 file was found for some nodes.\nCheck script editor."
			nuke.executeInMainThread( nuke.message, args=(msg) )
	else:
		pass