Example #1
0
    def browseFolder(self, lineEdit):
        """ Browse for a folder and put the result into the specified
			lineEdit field.
		"""
        starting_dir = os_wrapper.absolutePath(lineEdit.text())
        result = self.parent.folderDialog(starting_dir)
        if result:
            result = os_wrapper.relativePath(result, 'IC_ASSETLIBRARY')
            result = os_wrapper.relativePath(result, 'IC_FILESYSTEM_ROOT')
            lineEdit.setText(result)
Example #2
0
def read_create():
    """ Create a custom GPS Read node.
	"""
    readDir = os_wrapper.absolutePath('$IC_SHOTPATH/')
    dialogPathLs = nuke.getClipname('Read File(s)',
                                    default=readDir,
                                    multiple=True)
    if dialogPathLs:
        for dialogPath in dialogPathLs:
            try:
                filePath, frameRange = dialogPath.split(' ')
                startFrame, endFrame = frameRange.split('-')
            except ValueError:
                filePath = dialogPath
                startFrame, endFrame = os.environ['IC_STARTFRAME'], os.environ[
                    'IC_ENDFRAME']

            # Make filePath relative
            filePath = os_wrapper.relativePath(filePath,
                                               'IC_JOBPATH',
                                               tokenFormat='nuke')

            readNode = nuke.createNode('Read', 'name GPS_Read')
            readNode.knob('file').setValue(filePath)
            readNode.knob('cacheLocal').setValue('always')
            readNode.knob('cached').setValue('True')
            readNode.knob('first').setValue(int(startFrame))
            readNode.knob('last').setValue(int(endFrame))

        return readNode
Example #3
0
    def updateUserPrefsLocation(self, state, value):
        """ Update user prefs location based on the setting above.
		"""
        if state:
            if value == 'server':
                config_dir = self.frame.configDir_lineEdit.text()
                path = os.path.join(config_dir, 'users',
                                    os.environ['IC_USERNAME'])
            elif value == 'home':
                metadata = self.frame.metadataDir_lineEdit.text()
                path = os.path.join(os.environ['IC_USERHOME'], metadata)

            path = os_wrapper.absolutePath(path)
            path = os_wrapper.relativePath(path, 'IC_BASEDIR')
            path = os_wrapper.relativePath(path, 'IC_USERHOME')
            path = os_wrapper.relativePath(path, 'IC_USERNAME')
            self.frame.userPrefs_lineEdit.setText(path)
Example #4
0
    def browseDir(self):
        """ Open a dialog from which to select a folder.
		"""
        startingDir = os_wrapper.translatePath(self.ui.jobPath_lineEdit.text())
        if os.path.isdir(startingDir):
            dialogHome = startingDir
        else:
            dialogHome = os.environ['IC_JOBSROOT']

        # Append slash to path if it's a Windows drive letter, otherwise file
        # dialog won't open the correct location
        if dialogHome.endswith(':'):
            dialogHome += '/'

        #dialogPath = QtWidgets.QFileDialog.getExistingDirectory(self, self.tr('Directory'), dialogHome, QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly)
        ##dialog = QtWidgets.QFileDialog(self)
        dialogPath = self.folderDialog(dialogHome)

        if dialogPath:
            # if dialog.exec_():
            # 	dialogPath = dialog.getExistingDirectory(self, self.tr('Directory'), dialogHome, QtWidgets.QFileDialog.DontResolveSymlinks | QtWidgets.QFileDialog.ShowDirsOnly)
            if os_wrapper.checkIllegalChars(dialogPath):  #, r'[^\w\.-]'):
                jobPath = os_wrapper.relativePath(dialogPath, 'IC_JOBSROOT')
                self.ui.jobPath_lineEdit.setText(jobPath)
                # Only autofill job name field it it's empty
                if not self.ui.jobName_lineEdit.text():
                    try:
                        # if os.environ['IC_JOBSROOT'] in os_wrapper.absolutePath(jobPath):
                        #       jobName = jobPath.split('/')[1]
                        # else:
                        #       jobName = jobPath.split('/')[-1]
                        jobName = os.path.basename(jobPath)
                        self.ui.jobName_lineEdit.setText(jobName)
                    except IndexError:
                        pass

            else:
                verbose.illegalCharacters(dialogPath)

                # Warning dialog
                dialogTitle = "Path contains illegal characters"
                dialogMsg = "The path \"%s\" contains illegal characters. File and folder names must be formed of alphanumeric characters, underscores, hyphens and dots only." % dialogPath
                dialog = prompt.dialog()
                dialog.display(dialogMsg, dialogTitle, conf=True)
Example #5
0
def nkFileNodeExport(objLs, nodeType, fileName, pblDir, visiblePblDir,
                     assetPblName, version):
    """ Export Nuke node from Maya.
	"""
    pathtoPblAsset = os.path.join(pblDir, '%s.nk' % assetPblName)
    filePath = os.path.join(visiblePblDir, 'tx', fileName)

    # Make file path relative
    filePath = os_wrapper.relativePath(filePath,
                                       'IC_SHOTPUBLISHDIR',
                                       tokenFormat='nuke')

    nkFile = open(pathtoPblAsset, 'w')
    nkFile.write('''Read {
	inputs 0
	file "%s"
	cacheLocal always
	name %s
	selected true
	cached true\n}''' % (filePath, assetPblName))
    nkFile.close()
    return
Example #6
0
    def __init__(self, parent, frame):
        """ Setup application properties panel.
		"""
        self.frame = frame
        self.parent = parent

        # Set icons
        self.frame.configDirBrowse_toolButton.setIcon(
            parent.iconSet('folder-open.svg'))
        self.frame.assetLibraryBrowse_toolButton.setIcon(
            parent.iconSet('folder-open.svg'))

        # Connect signals & slots
        self.frame.configDirBrowse_toolButton.clicked.connect(
            lambda: self.browseFolder(self.frame.configDir_lineEdit))
        self.frame.assetLibraryBrowse_toolButton.clicked.connect(
            lambda: self.browseFolder(self.frame.assetLibrary_lineEdit))
        self.frame.userPrefsServer_radioButton.toggled.connect(
            lambda state: self.updateUserPrefsLocation(state, 'server'))
        self.frame.userPrefsHome_radioButton.toggled.connect(
            lambda state: self.updateUserPrefsLocation(state, 'home'))
        self.frame.editPaths_pushButton.clicked.connect(
            lambda: self.editPaths()
        )  # Only works with a lambda for some reason
        self.frame.editJobs_pushButton.clicked.connect(lambda: self.editJobs(
        ))  # Only works with a lambda for some reason

        # Instantiate jobs class and load data
        self.j = jobs.Jobs()

        # Display first run message
        if 'IC_FIRSTRUN' in os.environ:
            message = "This appears to be the first time Icarus has been started. Basic configuration needs to be set.\n\n%s" % self.frame.message_plainTextEdit.toPlainText(
            )
            self.frame.message_plainTextEdit.setPlainText(message)

        self.frame.configDir_lineEdit.setText(
            os_wrapper.relativePath(os.environ['IC_CONFIGDIR'], 'IC_BASEDIR'))
Example #7
0
    def renderTableUpdate(self):
        """ Populates the render layer tree view widget with entries.
		"""
        #renderPath = self.renderPath
        self.ui.renderBrowser_treeWidget.clear()
        renderPath = self.ui.path_lineEdit.text()
        # if renderPath:
        if os.path.isdir(renderPath):
            renderLayerDirs = []

            # Get subdirectories
            subdirs = next(os.walk(renderPath))[1]
            if subdirs:
                for subdir in subdirs:
                    if not subdir.startswith(
                            '.'):  # ignore directories that start with a dot
                        renderLayerDirs.append(subdir)
            if renderLayerDirs:
                renderLayerDirs.sort()
            else:  # use parent dir
                renderLayerDirs = [os.path.basename(renderPath)]
                renderPath = os.path.dirname(renderPath)
            #print renderPath, renderLayerDirs

            self.ui.renderBrowser_treeWidget.setIconSize(QtCore.QSize(128, 72))

            # Add render layers
            for renderLayerDir in renderLayerDirs:
                renderPasses = sequence.getBases(
                    os.path.join(renderPath, renderLayerDir))

                # Only continue if render pass sequences exist in this directory, and ignore directories that start with a dot
                if renderPasses and not renderLayerDir.startswith('.'):
                    renderLayerItem = QtWidgets.QTreeWidgetItem(
                        self.ui.renderBrowser_treeWidget)
                    renderLayerItem.setText(
                        0, '%s (%d)' % (renderLayerDir, len(renderPasses)))
                    renderLayerItem.setText(1, 'layer')
                    #renderLayerItem.setText(4, os.path.join(renderPath, renderLayerDir))
                    renderLayerItem.setText(
                        4,
                        os_wrapper.relativePath(
                            os.path.join(renderPath, renderLayerDir),
                            'SHOTPATH'))
                    self.ui.renderBrowser_treeWidget.addTopLevelItem(
                        renderLayerItem)
                    renderLayerItem.setExpanded(True)

                    # Add render passes
                    for renderPass in renderPasses:
                        renderPassItem = QtWidgets.QTreeWidgetItem(
                            renderLayerItem)
                        path, prefix, fr_range, ext, num_frames = sequence.getSequence(
                            os.path.join(renderPath, renderLayerDir),
                            renderPass)
                        renderPassItem.setText(0, prefix)
                        iconPath = self.generateThumbnail(
                            os.path.join(renderPath, renderLayerDir), prefix,
                            ext)
                        #print iconPath
                        renderPassItem.setIcon(0, QtGui.QIcon(iconPath))
                        renderPassItem.setText(1, ext.split('.', 1)[1])
                        renderPassItem.setText(2, fr_range)
                        # if not sequence.check(fr_range):  # Set red text for sequence mismatch
                        # 	renderPassItem.setForeground(2, QtGui.QBrush(QtGui.QColor("#f92672")))
                        #renderPassItem.setText(4, path)
                        renderPassItem.setText(
                            4,
                            os_wrapper.relativePath(
                                os.path.join(renderPath, renderLayerDir,
                                             renderPass), 'SHOTPATH'))
                        self.ui.renderBrowser_treeWidget.addTopLevelItem(
                            renderPassItem)

            # Resize columns
            self.ui.renderBrowser_treeWidget.resizeColumnToContents(0)
            self.ui.renderBrowser_treeWidget.resizeColumnToContents(1)
            self.ui.renderBrowser_treeWidget.resizeColumnToContents(2)