def _renderCurrent(self): session_key = random.randint(1,100) createNukeRenderScript(self.ID, session_key, self.properties) if readInitPath()["NUKE_PATH"]: nukePythonPath = readInitPath()["NUKE_PATH"] + "\\python.exe" if not os.path.exists(nukePythonPath): print("Nuke path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "NUKE_PATH ERROR" return False else: print("Nuke path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "NUKE_PATH ERROR" return False scriptPath = SCRIPT_PATH + "\\renderNukeScript_s{0}_id{1}.py".format(session_key, self.ID) p = subprocess.Popen([nukePythonPath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) p.wait() self.catchProcessInfo(p) if self.UI_PROPERTIES["clean_py"]: deleteNukeRenderScript(self.ID, session_key)
def _renderCurrent(self): session_key = random.randint(1, 100) createNukeRenderScript(self.ID, session_key, self.properties) if readInitPath()["NUKE_PATH"]: nukePythonPath = readInitPath()["NUKE_PATH"] + "\\python.exe" if not os.path.exists(nukePythonPath): print("Nuke path not correct, job {0} skipped.".format( self.ID)) self.ERROR = "NUKE_PATH ERROR" return False else: print("Nuke path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "NUKE_PATH ERROR" return False scriptPath = SCRIPT_PATH + "\\renderNukeScript_s{0}_id{1}.py".format( session_key, self.ID) p = subprocess.Popen([nukePythonPath, scriptPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) p.wait() self.catchProcessInfo(p) if self.UI_PROPERTIES["clean_py"]: deleteNukeRenderScript(self.ID, session_key)
def _loadMB(file_path, mode): ''' Load a mb file format with generated python script and mayapy ''' mayapy = readInitPath()["MAYA_PATH"] + "\\bin\\mayapy.exe" _loadMBScript(file_path, mode) script = SCRIPT_PATH + "\\tmpread_mb.py" p = subprocess.Popen([mayapy, script]) p.wait() # Fetch dic data pickleData = SCRIPT_PATH + "\\tmpread_mb_{0}.out".format(mode) with open(pickleData, 'rb') as handle: mayaDatas = pickle.load(handle) outData = {} tmpNode = {} if mayaDatas[0]: for i in mayaDatas[0]: tmpNode[i] = i else: tmpNode["None"] = "None" tmpLayer = {} for i in mayaDatas[1]: tmpLayer[i] = i outData["nodes"] = tmpNode outData["render_layer"] = tmpLayer return outData
def _renderCurrent(self): ''' Render current job launched from Worker Thread ''' session_key = random.randint(1,100) hythonPath = readInitPath()["HOUDINI_PATH"] if hythonPath: hythonPath = hythonPath + "\\bin\\hython.exe" if not os.path.exists(hythonPath): print("Houdini path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "HOUDINI_PATH ERROR" return False else: print("Houdini path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "HOUDINI_PATH ERROR" return False createHoudiniRenderScript(self.ID, session_key, self.properties) scriptPath = SCRIPT_PATH + "\\renderHoudiniScript_s{0}_id{1}.py".format(session_key, self.ID) p = subprocess.Popen([hythonPath, scriptPath]) p.wait() self.catchProcessInfo(p) if self.UI_PROPERTIES["clean_py"]: deleteHoudiniRenderScript(self.ID, session_key)
def _renderCurrent(self): ''' Render current job launched from Worker Thread ''' session_key = random.randint(1, 100) hythonPath = readInitPath()["HOUDINI_PATH"] if hythonPath: hythonPath = hythonPath + "\\bin\\hython.exe" if not os.path.exists(hythonPath): print("Houdini path not correct, job {0} skipped.".format( self.ID)) self.ERROR = "HOUDINI_PATH ERROR" return False else: print("Houdini path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "HOUDINI_PATH ERROR" return False createHoudiniRenderScript(self.ID, session_key, self.properties) scriptPath = SCRIPT_PATH + "\\renderHoudiniScript_s{0}_id{1}.py".format( session_key, self.ID) p = subprocess.Popen([hythonPath, scriptPath]) p.wait() self.catchProcessInfo(p) if self.UI_PROPERTIES["clean_py"]: deleteHoudiniRenderScript(self.ID, session_key)
def _loadMB(file_path, mode): ''' Load a mb file format with generated python script and mayapy ''' mayapy = readInitPath()["MAYA_PATH"] + "\\bin\\mayapy.exe" _loadMBScript(file_path, mode) script = SCRIPT_PATH + "\\tmpread_mb.py" p = subprocess.Popen([mayapy, script]) p.wait() # Fetch dic data pickleData =SCRIPT_PATH + "\\tmpread_mb_{0}.out".format(mode) with open(pickleData, 'rb') as handle: mayaDatas = pickle.load(handle) outData = {} tmpNode = {} if mayaDatas[0]: for i in mayaDatas[0]: tmpNode[i] = i else: tmpNode["None"] = "None" tmpLayer = {} for i in mayaDatas[1]: tmpLayer[i] = i outData["nodes"] = tmpNode outData["render_layer"] = tmpLayer return outData
def _renderCurrent(self): mayapath = readInitPath()["MAYA_PATH"] if mayapath: if not os.path.exists(mayapath): print("Maya path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "MAYA_PATH ERROR" return False else: print("Maya path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "MAYA_PATH ERROR" return False # Render a scene if self.properties["job_type"] == "Render Scene": MAYA_RENDER = '"'+ mayapath + "\\bin\\render.exe" + '" ' if self.properties["override_frames"]: MAYA_RENDER += "-s " + str(float(self.properties["start_frame"])) MAYA_RENDER += " -e " + str(float(self.properties["end_frame"])) MAYA_RENDER += " -b 1.0" MAYA_RENDER += " -fnc 3" MAYA_RENDER += " -pad " + str(len(str(self.properties["end_frame"]))) + " " if self.properties["override_camera"] and self.properties["camera"]: MAYA_RENDER += '-cam "' + str(self.properties["camera"]) + '" ' if self.properties["override_render_layer"] and self.properties["render_layer"]: MAYA_RENDER += '-rl "' + str(self.properties["render_layer"]).replace(",","").replace("[","").replace("]","").replace("'","") + '" ' if self.properties["override_output_path"] and self.properties["render_outputpath"]: MAYA_RENDER += "-rd " + '"' + self.properties["render_outputpath"].replace("/","\\") + '"' MAYA_RENDER += ' "' + self.properties["file_path"].replace("/","\\") + '"' with open(SCRIPT_PATH + "\\mayajobrendertmp.bat", 'w') as bat: bat.write(MAYA_RENDER) os.system(SCRIPT_PATH + "\\mayajobrendertmp.bat") # Export obj job elif self.properties["job_type"] == "Export obj": # Generate python script exportObjScript(self.properties["object_to_export"], self.properties["obj_outputpath"], self.properties["file_path"]) MAYAPY = '"' + mayapath + "\\bin\\mayapy.exe" + '"' with open(SCRIPT_PATH + "\\mayaExportObjTmp.bat", 'w') as bat: bat.write(MAYAPY + ' "' + SCRIPT_PATH + "\\exportObjTmp.py" +'"') os.system(SCRIPT_PATH + "\\mayaExportObjTmp.bat") if self.UI_PROPERTIES["clean_py"]: cleanTmpMayaFile()
def loadHip(hip_path, output, UI_PROPERTIES): ''' Load a hip file and return a dictionary of "renderNode" : node.path(). according to "RENDER_NODES_TYPE" ''' # Create python script createHouReadScript(hip_path) # Execute it houPath = readInitPath()["HOUDINI_PATH"] + "\\bin\\hython.exe" if not os.path.exists(SCRIPT_PATH): os.mkdir(SCRIPT_PATH) script = SCRIPT_PATH + "\\tmpread_hip.py" p = subprocess.Popen([houPath, script]) p.wait() # Fetch dic data pickleData =SCRIPT_PATH + "\\tmpread_hou_nodes.out" with open(pickleData, 'rb') as handle: render_nodes = pickle.load(handle) # Clean datas if menu switch is True if UI_PROPERTIES["clean_py"]: cleanHouScript() return render_nodes
def __init__(self, version, parent=None): QtGui.QMainWindow.__init__(self, parent=parent) self.version = version with open(DARK_STYLE, "r") as style: self.setStyleSheet(style.read()) #Main attrib self.setWindowTitle("hman v" + version) self.parentPath = os.path.dirname(__file__) self.parentPath = os.path.dirname(self.parentPath) self.setWindowIcon( QtGui.QIcon(self.parentPath + r"/icons/hman_small.png")) self.softwareLoaded = readInitPath() self.setGeometry(400, 150, 900, 800) self.cw = QtGui.QWidget() self.centralLayout = QtGui.QVBoxLayout() self.timerLabel = QtGui.QLabel("") # UI properties sent to differents methods if needed self.UI_PROPERTIES = {} # INIT UI self._initFlowViewHeader() self._initFlowview() self._initScrollArea() self._initPropertyDock() self._initOutputDock() self._initGraphdataDock() self._initProgressbar() self._initToolBar() self._initToolBarButtons() self._initMenus() self.statusBar().showMessage('Ready') self.tabifyDockWidget(self.outputDock, self.graphDataDock) self.outputDock.raise_() self.propertyDock.raise_() self.cw.setLayout(self.centralLayout) self.setCentralWidget(self.cw) # Options self.jobOptions = {"None": None}
def __init__(self, version, parent=None): QtGui.QMainWindow.__init__(self, parent=parent) self.version = version with open(DARK_STYLE,"r") as style: self.setStyleSheet(style.read()) #Main attrib self.setWindowTitle("hman v" + version) self.parentPath = os.path.dirname(__file__) self.parentPath = os.path.dirname(self.parentPath) self.setWindowIcon(QtGui.QIcon(self.parentPath + r"/icons/hman_small.png")) self.softwareLoaded = readInitPath() self.setGeometry(400,150,900,800) self.cw = QtGui.QWidget() self.centralLayout = QtGui.QVBoxLayout() self.timerLabel = QtGui.QLabel("") # UI properties sent to differents methods if needed self.UI_PROPERTIES = {} # INIT UI self._initFlowViewHeader() self._initFlowview() self._initScrollArea() self._initPropertyDock() self._initOutputDock() self._initGraphdataDock() self._initProgressbar() self._initToolBar() self._initToolBarButtons() self._initMenus() self.statusBar().showMessage('Ready') self.tabifyDockWidget(self.outputDock, self.graphDataDock) self.outputDock.raise_() self.propertyDock.raise_() self.cw.setLayout(self.centralLayout) self.setCentralWidget(self.cw) # Options self.jobOptions = {"None":None}
def ok(self): ''' Check if path are valid and close the ui if valid. ''' pathResult = [] for i in [self.mayaPath, self.houdiniPath, self.nukePath]: if os.path.exists(i.text()): pathResult.append(str(i.text())) else: pathResult.append(False) # Check if at least one path is valid if not any(pathResult): warnPop = QtGui.QMessageBox(self) warnPop.setWindowTitle("Path error") warnPop.setText("ERROR: At least one of the path must be valid.") warnPop.exec_() else: # Restart app self.close() writeInitPath(self.outSoftwarePath) if self.mainUI: newpath = readInitPath() if newpath["MAYA_PATH"]: self.mainUI.addMayaJobMenu.setEnabled(True) self.mainUI.addMayaJob.setEnabled(True) else: self.mainUI.addMayaJobMenu.setEnabled(False) self.mainUI.addMayaJob.setEnabled(False) if newpath["HOUDINI_PATH"]: self.mainUI.addHoudiniJobMenu.setEnabled(True) self.mainUI.addHoudiniJob.setEnabled(True) else: self.mainUI.addHoudiniJobMenu.setEnabled(False) self.mainUI.addHoudiniJob.setEnabled(False) if newpath["NUKE_PATH"]: self.mainUI.addNukeJobMenu.setEnabled(True) self.mainUI.addNukeJob.setEnabled(True) else: self.mainUI.addNukeJobMenu.setEnabled(False) self.mainUI.addNukeJob.setEnabled(False)
def main(parent=None): # Check if folder _pytmp exists pymp = os.path.dirname(__file__) + "\\_pytmp" if not os.path.exists(pymp): os.mkdir(pymp) # Check hman version version = "version" with open(version, "r") as v: version = v.readline() msg = "INFO: " msg += "Launching hman version: " + version LogW.writeLog(None, msg, printout=True) outDic = readInitPath() pathResult = [outDic[k] for k in outDic.keys()] # Taskbar icon fix for windows 7 try: import ctypes myappid = u'hman' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) except ImportError: pass app = QtGui.QApplication(sys.argv) app.setWindowIcon( QtGui.QIcon(os.path.dirname(__file__) + "\\icons\\hman_small.png")) # If no path found, launch ui if not any(pathResult): pathPicker = PathPicker(version, parent) pathPicker.exec_() if pathPicker.CANCEL: return ui = HmanMainUi(version, parent) ui.show() app.exec_()
def main(parent=None): # Check if folder _pytmp exists pymp = os.path.dirname(__file__) + "\\_pytmp" if not os.path.exists(pymp): os.mkdir(pymp) # Check hman version version = "version" with open(version, "r") as v: version = v.readline() msg = "INFO: " msg += "Launching hman version: " + version LogW.writeLog(None, msg, printout=True) outDic = readInitPath() pathResult = [outDic[k] for k in outDic.keys()] # Taskbar icon fix for windows 7 try: import ctypes myappid = u'hman' ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid) except ImportError: pass app = QtGui.QApplication(sys.argv) app.setWindowIcon(QtGui.QIcon(os.path.dirname(__file__)+"\\icons\\hman_small.png")) # If no path found, launch ui if not any(pathResult): pathPicker = PathPicker(version, parent) pathPicker.exec_() if pathPicker.CANCEL: return ui = HmanMainUi(version, parent) ui.show() app.exec_()
def loadNukeScript(nuke_script): ''' Read a nuke script and fetch all write node. This does not use nuke's python. ''' NUKE_PATH = readInitPath()["NUKE_PATH"] if NUKE_PATH: if os.path.exists(nuke_script): datas = [] outNodeTmp = [] with open(nuke_script, 'r') as nk: datas = nk.readlines() for i in range(len(datas)): if datas[i].endswith("{\n"): tmp = [] tmp.append(datas[i].replace("{\n","").replace(" ","")) k = 1 while not datas[i+k].endswith("}\n"): tmp.append(datas[i+k]) k+=1 outNodeTmp.append(tmp) outWriteNodes = [] for n in outNodeTmp: if n[0] == "Write": for k in n: if k.replace(" ", "").startswith("name"): outWriteNodes.append(k.split("name")[1].replace(" ", "").replace("\n","")) return outWriteNodes
def _renderCurrent(self): mayapath = readInitPath()["MAYA_PATH"] if mayapath: if not os.path.exists(mayapath): print("Maya path not correct, job {0} skipped.".format( self.ID)) self.ERROR = "MAYA_PATH ERROR" return False else: print("Maya path not correct, job {0} skipped.".format(self.ID)) self.ERROR = "MAYA_PATH ERROR" return False # Render a scene if self.properties["job_type"] == "Render Scene": MAYA_RENDER = '"' + mayapath + "\\bin\\render.exe" + '" ' if self.properties["override_frames"]: MAYA_RENDER += "-s " + str( float(self.properties["start_frame"])) MAYA_RENDER += " -e " + str(float( self.properties["end_frame"])) MAYA_RENDER += " -b 1.0" MAYA_RENDER += " -fnc 3" MAYA_RENDER += " -pad " + str( len(str(self.properties["end_frame"]))) + " " if self.properties["override_camera"] and self.properties["camera"]: MAYA_RENDER += '-cam "' + str(self.properties["camera"]) + '" ' if self.properties["override_render_layer"] and self.properties[ "render_layer"]: MAYA_RENDER += '-rl "' + str( self.properties["render_layer"]).replace(",", "").replace( "[", "").replace("]", "").replace("'", "") + '" ' if self.properties["override_output_path"] and self.properties[ "render_outputpath"]: MAYA_RENDER += "-rd " + '"' + self.properties[ "render_outputpath"].replace("/", "\\") + '"' MAYA_RENDER += ' "' + self.properties["file_path"].replace( "/", "\\") + '"' with open(SCRIPT_PATH + "\\mayajobrendertmp.bat", 'w') as bat: bat.write(MAYA_RENDER) os.system(SCRIPT_PATH + "\\mayajobrendertmp.bat") # Export obj job elif self.properties["job_type"] == "Export obj": # Generate python script exportObjScript(self.properties["object_to_export"], self.properties["obj_outputpath"], self.properties["file_path"]) MAYAPY = '"' + mayapath + "\\bin\\mayapy.exe" + '"' with open(SCRIPT_PATH + "\\mayaExportObjTmp.bat", 'w') as bat: bat.write(MAYAPY + ' "' + SCRIPT_PATH + "\\exportObjTmp.py" + '"') os.system(SCRIPT_PATH + "\\mayaExportObjTmp.bat") if self.UI_PROPERTIES["clean_py"]: cleanTmpMayaFile()
def loadFlowview(self): ''' Load a hman file (flowview) It also check if software path are correct, if not found the job will be bypassed and a warning will be printed. ''' software_path = readInitPath(False) path_warning = False p = QtGui.QFileDialog.getOpenFileNames(parent=None, filter="hman Files (*.hman)") REPLACE = False if self.jobs and p: ask = QtGui.QMessageBox( QtGui.QMessageBox.Warning, "Warning", "Jobs already found in the Flowview.\nDo you want to Append new jobs or replace current jobs ?", parent=self) ask.addButton('Append', QtGui.QMessageBox.NoRole) ask.addButton('Replace', QtGui.QMessageBox.YesRole) ask.addButton('Cancel', QtGui.QMessageBox.RejectRole) ret = ask.exec_() if ret == 2: return elif ret == 1: REPLACE = True self.clearJobs() self.propertyDock.hideProperties(clear=True) for i in self.jobs: print i if p: for f in p: datas = None with open(str(f), 'rb') as handle: datas = pickle.load(handle) # Change flowview label if REPLACE or not self.jobs: self.mainUI.flowLabel.setText(str(datas[0])) datas = datas[1:] for data in datas: if data["jobtype"] == JobTypes.MAYA: w = MayaJobWidget(self.propertyDock, data["ID"] + (len(self.jobs) - data["ID"]), self, self.outputDock.output, self.UI_PROPERTIES, parent=self) if not software_path["MAYA_PATH"]: self.outputDock.writeLog( ErrorStr.ErrorStr.ERROR + "Maya path not correct, job disabled.") w.bypassWidget() path_warning = True elif data["jobtype"] == JobTypes.NUKE: w = NukeJobWidget(self.propertyDock, data["ID"] + (len(self.jobs) - data["ID"]), self, self.outputDock.output, self.UI_PROPERTIES, parent=self) if not software_path["NUKE_PATH"]: self.outputDock.writeLog( ErrorStr.ErrorStr.ERROR + "Nuke path not correct, job disabled.") w.bypassWidget() path_warning = True elif data["jobtype"] == JobTypes.HOUDINI: w = HoudiniJobWidget(self.propertyDock, data["ID"] + (len(self.jobs) - data["ID"]), self, self.outputDock.output, self.UI_PROPERTIES, parent=self) if not software_path["HOUDINI_PATH"]: self.outputDock.writeLog( ErrorStr.ErrorStr.ERROR + "Houdini path not correct, job disabled.") w.bypassWidget() path_warning = True elif data["jobtype"] == JobTypes.PYTHON: w = PythonJobWidget(self.propertyDock, data["ID"] + (len(self.jobs) - data["ID"]), self, self.outputDock.output, parent=self) elif data["jobtype"] == JobTypes.BATCH: w = BatchJobWidget(self.propertyDock, data["ID"] + (len(self.jobs) - data["ID"]), self, self.outputDock.output, parent=self) w.properties = data["properties"] if data["properties"]["file_path"]: w.pathLabel.setText("Path: " + data["properties"]["file_path"]) self.addJob(w) if path_warning: msg = ErrorStr.ErrorStr.WARNING + " {0} loaded with path warning(s). Some jobs are disabled.".format( str(f)) else: msg = ErrorStr.ErrorStr.INFO + " {0} loaded successfully.".format( str(f)) LogW.writeLog(self.outputDock.output, msg)
def _initToolBar(self): # Software found self.software = readInitPath() # Toolbar self.toolbar = QtGui.QToolBar() self.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolbar) # New Document Button self.newdocbtn = QtGui.QAction("Create a new flowview", self) self.newdocbtn.setIcon( QtGui.QIcon(self.parentPath + r"/icons/newDocument.png")) self.newdocbtn.triggered.connect(self.createNewFlow) self.newdocbtn.setStatusTip("Create a new flowview") # Open Document Button self.openDocBtn = QtGui.QAction("Open a flowview file", self) self.openDocBtn.triggered.connect(self.flowView.loadFlowview) self.openDocBtn.setIcon( QtGui.QIcon(self.parentPath + r"/icons/open.png")) self.openDocBtn.setStatusTip("Open a flowview file") # Save Document Button self.saveDocBtn = QtGui.QAction("Save current flowview", self) self.saveDocBtn.setIcon( QtGui.QIcon(self.parentPath + r"/icons/save.png")) self.saveDocBtn.triggered.connect(self.flowView.saveFlowview) self.saveDocBtn.setStatusTip("Save current flowview") # Maya button self.addMayaJob = QtGui.QAction("Add Maya Job", self) self.addMayaJob.setIcon( QtGui.QIcon(self.parentPath + r"/icons/maya.png")) self.addMayaJob.setStatusTip("Add a Maya job") self.addMayaJob.triggered.connect( lambda: self.addJobToFLowView(JobTypes.MAYA)) # Houdini button self.addHoudiniJob = QtGui.QAction("Add Houdini Job", self) self.addHoudiniJob.setIcon( QtGui.QIcon(self.parentPath + r"/icons/houdini.png")) self.addHoudiniJob.setStatusTip("Add a Houdini job") self.addHoudiniJob.triggered.connect( lambda: self.addJobToFLowView(JobTypes.HOUDINI)) # Nuke button self.addNukeJob = QtGui.QAction("Add Nuke Job", self) self.addNukeJob.setIcon( QtGui.QIcon(self.parentPath + r"/icons/nuke.png")) self.addNukeJob.setStatusTip("Add a Nuke job") self.addNukeJob.triggered.connect( lambda: self.addJobToFLowView(JobTypes.NUKE)) # Python button self.addPythonJob = QtGui.QAction("Add Python Job", self) self.addPythonJob.setIcon( QtGui.QIcon(self.parentPath + r"/icons/python.png")) self.addPythonJob.setStatusTip("Add a Python job") self.addPythonJob.triggered.connect( lambda: self.addJobToFLowView(JobTypes.PYTHON)) # Batch button self.addBatchJob = QtGui.QAction("Add Batch Job", self) self.addBatchJob.setIcon( QtGui.QIcon(self.parentPath + r"/icons/batch.png")) self.addBatchJob.setStatusTip("Add a Batch file job") self.addBatchJob.triggered.connect( lambda: self.addJobToFLowView(JobTypes.BATCH)) # Clear jobs button self.clearJobs = QtGui.QAction("Clear Jobs", self) self.clearJobs.setIcon( QtGui.QIcon(self.parentPath + r"/icons/clear.png")) self.clearJobs.setStatusTip("Clear all jobs") self.clearJobs.triggered.connect(self.clearJobsFromFlowView) # About button self.aboutBtn = QtGui.QAction("About", self) self.aboutBtn.setIcon( QtGui.QIcon(self.parentPath + r"/icons/hman_large.png")) self.aboutBtn.setStatusTip("About") self.aboutBtn.triggered.connect( lambda: CheckVersion.about(self.version)) # Quit button self.quitBtn = QtGui.QAction("Quit hman", self) self.quitBtn.setIcon(QtGui.QIcon(self.parentPath + r"/icons/exit.png")) self.quitBtn.setStatusTip("Quit hman") self.quitBtn.triggered.connect(self.close) self.toolbar.addAction(self.newdocbtn) self.toolbar.addAction(self.saveDocBtn) self.toolbar.addAction(self.openDocBtn) self.toolbar.addSeparator() self.toolbar.addAction(self.addMayaJob) self.toolbar.addAction(self.addHoudiniJob) self.toolbar.addAction(self.addNukeJob) self.toolbar.addSeparator() self.toolbar.addAction(self.addPythonJob) self.toolbar.addAction(self.addBatchJob) self.toolbar.addSeparator() self.toolbar.addAction(self.clearJobs) self.toolbar.addSeparator() self.toolbar.addAction(self.aboutBtn) self.toolbar.addAction(self.quitBtn)
def __init__(self, version, parent=None): QtGui.QMainWindow.__init__(self, parent=parent) self.setWindowTitle("Hman path picker v" + version) style = os.path.dirname(__file__) + "\\dark.style" style = style.replace("\\main", "") with open(style, "r") as style: self.setStyleSheet(style.read()) self.mainUI = None self.CANCEL = False # Out value self.outSoftwarePath = { "MAYA_PATH": False, "HOUDINI_PATH": False, "NUKE_PATH": False } # Fetch path path = readInitPath() mayaPathDefault = "" if path["MAYA_PATH"]: mayaPathDefault = path["MAYA_PATH"] self.outSoftwarePath["MAYA_PATH"] = path["MAYA_PATH"] houdiniPathDefault = "" if path["HOUDINI_PATH"]: houdiniPathDefault = path["HOUDINI_PATH"] self.outSoftwarePath["HOUDINI_PATH"] = path["HOUDINI_PATH"] nukePathDefault = "" if path["NUKE_PATH"]: nukePathDefault = path["NUKE_PATH"] self.outSoftwarePath["NUKE_PATH"] = path["NUKE_PATH"] # Master layout masterLay = QtGui.QHBoxLayout() masterLay.setSpacing(10) # Construct UI self.setMinimumWidth(850) self.setWindowIcon( QtGui.QIcon( os.path.dirname(os.path.dirname(__file__)) + "\\icons\\hman_small.png")) cw = QtGui.QWidget() mainLayout = QtGui.QVBoxLayout() mainLayout.setSpacing(10) logo = QtGui.QLabel("") logo.setFixedSize(QtCore.QSize(150, 180)) pixIco = QtGui.QPixmap( os.path.dirname(os.path.dirname(__file__)) + "\\icons\\hman_logo.png") #pixIco = pixIco.scaled(100, 100) logo.setPixmap(pixIco) masterLay.addWidget(logo) self.mainLabel = QtGui.QLabel( "Enter software path, keep blank of not installed:") # Maya info mayaLayout = QtGui.QHBoxLayout() mayaLayout.setSpacing(10) mayaLabel = QtGui.QLabel("Maya Path:") mayaLabel.setFixedWidth(70) self.mayaPath = QtGui.QLineEdit(mayaPathDefault) self.mayaPath.textChanged.connect( lambda: self.changeText(self.mayaPath, "MAYA")) self.mayaBtn = QtGui.QPushButton("Pick Maya Path") self.mayaBtn.setFixedWidth(100) self.mayaBtn.setObjectName("pushbutton") self.mayaBtn.clicked.connect( lambda: self.pickPath(self.mayaPath, "Maya")) mayaLayout.addWidget(mayaLabel) mayaLayout.addWidget(self.mayaPath) mayaLayout.addWidget(self.mayaBtn) # Houdini info houdiniLayout = QtGui.QHBoxLayout() houdiniLayout.setSpacing(10) houdiniLabel = QtGui.QLabel("Houdini Path:") houdiniLabel.setFixedWidth(70) self.houdiniPath = QtGui.QLineEdit(houdiniPathDefault) self.houdiniPath.textChanged.connect( lambda: self.changeText(self.houdiniPath, "HOUDINI")) self.houdiniBtn = QtGui.QPushButton("Pick Houdini Path") self.houdiniBtn.clicked.connect( lambda: self.pickPath(self.houdiniPath, "Houdini")) self.houdiniBtn.setFixedWidth(100) self.houdiniBtn.setObjectName("pushbutton") houdiniLayout.addWidget(houdiniLabel) houdiniLayout.addWidget(self.houdiniPath) houdiniLayout.addWidget(self.houdiniBtn) # nuke info nukeLayout = QtGui.QHBoxLayout() nukeLayout.setSpacing(10) nukeLabel = QtGui.QLabel("Nuke Path:") nukeLabel.setFixedWidth(70) self.nukePath = QtGui.QLineEdit(nukePathDefault) self.nukePath.textChanged.connect( lambda: self.changeText(self.nukePath, "NUKE")) self.nukeBtn = QtGui.QPushButton("Pick nuke Path") self.nukeBtn.setFixedWidth(100) self.nukeBtn.clicked.connect( lambda: self.pickPath(self.nukePath, "nuke")) self.nukeBtn.setObjectName("pushbutton") nukeLayout.addWidget(nukeLabel) nukeLayout.addWidget(self.nukePath) nukeLayout.addWidget(self.nukeBtn) # Ok / Cancel layout layoutBtn = QtGui.QHBoxLayout() layoutBtn.setSpacing(10) self.okBtn = QtGui.QPushButton("Ok") self.okBtn.setFixedWidth(120) self.okBtn.clicked.connect(self.ok) self.okBtn.setObjectName("pushbutton") self.cancelBtn = QtGui.QPushButton("Cancel") self.cancelBtn.setFixedWidth(120) self.cancelBtn.clicked.connect(self.cancel) self.cancelBtn.setObjectName("pushbutton") layoutBtn.addWidget(self.okBtn) layoutBtn.addWidget(self.cancelBtn) layoutBtn.setAlignment(QtCore.Qt.AlignRight) mainLayout.addWidget(self.mainLabel) mainLayout.addItem(mayaLayout) mainLayout.addItem(houdiniLayout) mainLayout.addItem(nukeLayout) mainLayout.addItem(layoutBtn) masterLay.addItem(mainLayout) cw.setLayout(masterLay) self.setLayout(masterLay)
def __init__(self, version, parent=None): QtGui.QMainWindow.__init__(self, parent=parent) self.setWindowTitle("Hman path picker v" + version) style = os.path.dirname(__file__) + "\\dark.style" style = style.replace("\\main","") with open( style ,"r") as style: self.setStyleSheet(style.read()) self.mainUI = None self.CANCEL = False # Out value self.outSoftwarePath = {"MAYA_PATH":False, "HOUDINI_PATH":False, "NUKE_PATH":False} # Fetch path path = readInitPath() mayaPathDefault = "" if path["MAYA_PATH"]: mayaPathDefault = path["MAYA_PATH"] self.outSoftwarePath["MAYA_PATH"] = path["MAYA_PATH"] houdiniPathDefault = "" if path["HOUDINI_PATH"]: houdiniPathDefault = path["HOUDINI_PATH"] self.outSoftwarePath["HOUDINI_PATH"] = path["HOUDINI_PATH"] nukePathDefault = "" if path["NUKE_PATH"]: nukePathDefault = path["NUKE_PATH"] self.outSoftwarePath["NUKE_PATH"] = path["NUKE_PATH"] # Master layout masterLay = QtGui.QHBoxLayout() masterLay.setSpacing(10) # Construct UI self.setMinimumWidth(850) self.setWindowIcon(QtGui.QIcon(os.path.dirname(os.path.dirname(__file__)) + "\\icons\\hman_small.png")) cw = QtGui.QWidget() mainLayout = QtGui.QVBoxLayout() mainLayout.setSpacing(10) logo = QtGui.QLabel("") logo.setFixedSize(QtCore.QSize(150,180)) pixIco = QtGui.QPixmap(os.path.dirname(os.path.dirname(__file__)) + "\\icons\\hman_logo.png") #pixIco = pixIco.scaled(100, 100) logo.setPixmap(pixIco) masterLay.addWidget(logo) self.mainLabel = QtGui.QLabel("Enter software path, keep blank of not installed:") # Maya info mayaLayout = QtGui.QHBoxLayout() mayaLayout.setSpacing(10) mayaLabel = QtGui.QLabel("Maya Path:") mayaLabel.setFixedWidth(70) self.mayaPath = QtGui.QLineEdit(mayaPathDefault) self.mayaPath.textChanged.connect(lambda: self.changeText(self.mayaPath, "MAYA")) self.mayaBtn = QtGui.QPushButton("Pick Maya Path") self.mayaBtn.setFixedWidth(100) self.mayaBtn.setObjectName("pushbutton") self.mayaBtn.clicked.connect(lambda: self.pickPath(self.mayaPath, "Maya")) mayaLayout.addWidget(mayaLabel) mayaLayout.addWidget(self.mayaPath) mayaLayout.addWidget(self.mayaBtn) # Houdini info houdiniLayout = QtGui.QHBoxLayout() houdiniLayout.setSpacing(10) houdiniLabel = QtGui.QLabel("Houdini Path:") houdiniLabel.setFixedWidth(70) self.houdiniPath = QtGui.QLineEdit(houdiniPathDefault) self.houdiniPath.textChanged.connect(lambda: self.changeText(self.houdiniPath, "HOUDINI")) self.houdiniBtn = QtGui.QPushButton("Pick Houdini Path") self.houdiniBtn.clicked.connect(lambda: self.pickPath(self.houdiniPath, "Houdini")) self.houdiniBtn.setFixedWidth(100) self.houdiniBtn.setObjectName("pushbutton") houdiniLayout.addWidget(houdiniLabel) houdiniLayout.addWidget(self.houdiniPath) houdiniLayout.addWidget(self.houdiniBtn) # nuke info nukeLayout = QtGui.QHBoxLayout() nukeLayout.setSpacing(10) nukeLabel = QtGui.QLabel("Nuke Path:") nukeLabel.setFixedWidth(70) self.nukePath = QtGui.QLineEdit(nukePathDefault) self.nukePath.textChanged.connect(lambda: self.changeText(self.nukePath, "NUKE")) self.nukeBtn = QtGui.QPushButton("Pick nuke Path") self.nukeBtn.setFixedWidth(100) self.nukeBtn.clicked.connect(lambda: self.pickPath(self.nukePath, "nuke")) self.nukeBtn.setObjectName("pushbutton") nukeLayout.addWidget(nukeLabel) nukeLayout.addWidget(self.nukePath) nukeLayout.addWidget(self.nukeBtn) # Ok / Cancel layout layoutBtn = QtGui.QHBoxLayout() layoutBtn.setSpacing(10) self.okBtn = QtGui.QPushButton("Ok") self.okBtn.setFixedWidth(120) self.okBtn.clicked.connect(self.ok) self.okBtn.setObjectName("pushbutton") self.cancelBtn = QtGui.QPushButton("Cancel") self.cancelBtn.setFixedWidth(120) self.cancelBtn.clicked.connect(self.cancel) self.cancelBtn.setObjectName("pushbutton") layoutBtn.addWidget(self.okBtn) layoutBtn.addWidget(self.cancelBtn) layoutBtn.setAlignment(QtCore.Qt.AlignRight) mainLayout.addWidget(self.mainLabel) mainLayout.addItem(mayaLayout) mainLayout.addItem(houdiniLayout) mainLayout.addItem(nukeLayout) mainLayout.addItem(layoutBtn) masterLay.addItem(mainLayout) cw.setLayout(masterLay) self.setLayout(masterLay)
def loadFlowview(self): ''' Load a hman file (flowview) It also check if software path are correct, if not found the job will be bypassed and a warning will be printed. ''' software_path = readInitPath(False) path_warning = False p = QtGui.QFileDialog.getOpenFileNames(parent=None, filter = "hman Files (*.hman)") REPLACE = False if self.jobs and p: ask = QtGui.QMessageBox(QtGui.QMessageBox.Warning,"Warning", "Jobs already found in the Flowview.\nDo you want to Append new jobs or replace current jobs ?",parent = self) ask.addButton('Append', QtGui.QMessageBox.NoRole) ask.addButton('Replace', QtGui.QMessageBox.YesRole) ask.addButton('Cancel', QtGui.QMessageBox.RejectRole) ret = ask.exec_(); if ret == 2: return elif ret == 1: REPLACE = True self.clearJobs() self.propertyDock.hideProperties(clear=True) for i in self.jobs: print i if p: for f in p: datas = None with open(str(f), 'rb') as handle: datas = pickle.load(handle) # Change flowview label if REPLACE or not self.jobs: self.mainUI.flowLabel.setText(str(datas[0])) datas = datas[1:] for data in datas: if data["jobtype"] == JobTypes.MAYA: w = MayaJobWidget(self.propertyDock, data["ID"] + (len(self.jobs)-data["ID"]), self, self.outputDock.output, self.UI_PROPERTIES, parent=self) if not software_path["MAYA_PATH"]: self.outputDock.writeLog(ErrorStr.ErrorStr.ERROR + "Maya path not correct, job disabled.") w.bypassWidget() path_warning = True elif data["jobtype"] == JobTypes.NUKE: w = NukeJobWidget(self.propertyDock, data["ID"] + (len(self.jobs)-data["ID"]), self, self.outputDock.output, self.UI_PROPERTIES, parent=self) if not software_path["NUKE_PATH"]: self.outputDock.writeLog(ErrorStr.ErrorStr.ERROR + "Nuke path not correct, job disabled.") w.bypassWidget() path_warning = True elif data["jobtype"] == JobTypes.HOUDINI: w = HoudiniJobWidget( self.propertyDock, data["ID"] + (len(self.jobs)-data["ID"]), self, self.outputDock.output, self.UI_PROPERTIES, parent=self) if not software_path["HOUDINI_PATH"]: self.outputDock.writeLog(ErrorStr.ErrorStr.ERROR + "Houdini path not correct, job disabled.") w.bypassWidget() path_warning = True elif data["jobtype"] == JobTypes.PYTHON: w = PythonJobWidget( self.propertyDock, data["ID"] + (len(self.jobs)-data["ID"]), self, self.outputDock.output, parent=self) elif data["jobtype"] == JobTypes.BATCH: w = BatchJobWidget( self.propertyDock, data["ID"] + (len(self.jobs)-data["ID"]), self, self.outputDock.output, parent=self) w.properties = data["properties"] if data["properties"]["file_path"]: w.pathLabel.setText("Path: " + data["properties"]["file_path"]) self.addJob(w) if path_warning: msg = ErrorStr.ErrorStr.WARNING + " {0} loaded with path warning(s). Some jobs are disabled.".format(str(f)) else: msg = ErrorStr.ErrorStr.INFO + " {0} loaded successfully.".format(str(f)) LogW.writeLog(self.outputDock.output, msg)
def _initToolBar(self): # Software found self.software = readInitPath() # Toolbar self.toolbar = QtGui.QToolBar() self.addToolBar(QtCore.Qt.LeftToolBarArea, self.toolbar) # New Document Button self.newdocbtn = QtGui.QAction("Create a new flowview", self) self.newdocbtn.setIcon(QtGui.QIcon(self.parentPath + r"/icons/newDocument.png")) self.newdocbtn.triggered.connect(self.createNewFlow) self.newdocbtn.setStatusTip("Create a new flowview") # Open Document Button self.openDocBtn = QtGui.QAction("Open a flowview file", self) self.openDocBtn.triggered.connect(self.flowView.loadFlowview) self.openDocBtn.setIcon(QtGui.QIcon(self.parentPath + r"/icons/open.png")) self.openDocBtn.setStatusTip("Open a flowview file") # Save Document Button self.saveDocBtn = QtGui.QAction("Save current flowview", self) self.saveDocBtn.setIcon(QtGui.QIcon(self.parentPath + r"/icons/save.png")) self.saveDocBtn.triggered.connect(self.flowView.saveFlowview) self.saveDocBtn.setStatusTip("Save current flowview") # Maya button self.addMayaJob = QtGui.QAction("Add Maya Job", self) self.addMayaJob.setIcon(QtGui.QIcon(self.parentPath + r"/icons/maya.png")) self.addMayaJob.setStatusTip("Add a Maya job") self.addMayaJob.triggered.connect(lambda: self.addJobToFLowView(JobTypes.MAYA)) # Houdini button self.addHoudiniJob = QtGui.QAction("Add Houdini Job", self) self.addHoudiniJob.setIcon(QtGui.QIcon(self.parentPath + r"/icons/houdini.png")) self.addHoudiniJob.setStatusTip("Add a Houdini job") self.addHoudiniJob.triggered.connect(lambda: self.addJobToFLowView(JobTypes.HOUDINI)) # Nuke button self.addNukeJob = QtGui.QAction("Add Nuke Job", self) self.addNukeJob.setIcon(QtGui.QIcon(self.parentPath + r"/icons/nuke.png")) self.addNukeJob.setStatusTip("Add a Nuke job") self.addNukeJob.triggered.connect(lambda: self.addJobToFLowView(JobTypes.NUKE)) # Python button self.addPythonJob = QtGui.QAction("Add Python Job", self) self.addPythonJob.setIcon(QtGui.QIcon(self.parentPath + r"/icons/python.png")) self.addPythonJob.setStatusTip("Add a Python job") self.addPythonJob.triggered.connect(lambda: self.addJobToFLowView(JobTypes.PYTHON)) # Batch button self.addBatchJob = QtGui.QAction("Add Batch Job", self) self.addBatchJob.setIcon(QtGui.QIcon(self.parentPath + r"/icons/batch.png")) self.addBatchJob.setStatusTip("Add a Batch file job") self.addBatchJob.triggered.connect(lambda: self.addJobToFLowView(JobTypes.BATCH)) # Clear jobs button self.clearJobs = QtGui.QAction("Clear Jobs", self) self.clearJobs.setIcon(QtGui.QIcon(self.parentPath + r"/icons/clear.png")) self.clearJobs.setStatusTip("Clear all jobs") self.clearJobs.triggered.connect(self.clearJobsFromFlowView) # About button self.aboutBtn = QtGui.QAction("About", self) self.aboutBtn.setIcon(QtGui.QIcon(self.parentPath + r"/icons/hman_large.png")) self.aboutBtn.setStatusTip("About") self.aboutBtn.triggered.connect(lambda: CheckVersion.about(self.version)) # Quit button self.quitBtn = QtGui.QAction("Quit hman", self) self.quitBtn.setIcon(QtGui.QIcon(self.parentPath + r"/icons/exit.png")) self.quitBtn.setStatusTip("Quit hman") self.quitBtn.triggered.connect(self.close) self.toolbar.addAction(self.newdocbtn) self.toolbar.addAction(self.saveDocBtn) self.toolbar.addAction(self.openDocBtn) self.toolbar.addSeparator() self.toolbar.addAction(self.addMayaJob) self.toolbar.addAction(self.addHoudiniJob) self.toolbar.addAction(self.addNukeJob) self.toolbar.addSeparator() self.toolbar.addAction(self.addPythonJob) self.toolbar.addAction(self.addBatchJob) self.toolbar.addSeparator() self.toolbar.addAction(self.clearJobs) self.toolbar.addSeparator() self.toolbar.addAction(self.aboutBtn) self.toolbar.addAction(self.quitBtn)