def validate(self, uiWidget, origText=None, allowChars=[]): if origText is None: origText = uiWidget.text() text = self.core.validateStr(origText, allowChars=allowChars) if len(text) != len(origText): cpos = uiWidget.cursorPosition() uiWidget.setText(text) uiWidget.setCursorPosition(cpos-1) @err_decorator def startTray(self): command = '\"%s\\Python27\\PandoraTray.exe\" \"%s\\Scripts\\PandoraTray.py\"' % (self.core.pandoraRoot, self.core.pandoraRoot) subprocess.Popen(command, shell=True) @err_decorator def enterEvent(self, event): QApplication.restoreOverrideCursor() if __name__ == "__main__": qApp = QApplication(sys.argv) qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True)) handlerIcon = QIcon(os.path.dirname(os.path.abspath(__file__)) + "\\UserInterfacesPandora\\pandora_tray.ico") qApp.setWindowIcon(handlerIcon) import PandoraCore pc = PandoraCore.PandoraCore() pc.openSettings() qApp.exec_()
def install(patch=False, user=""): try: pList = InstallList.InstallList() pList.setModal(True) pList.tw_components.header().resizeSection(0,200) pList.tw_components.itemDoubleClicked.connect(openBrowse) refreshUI(pList, user) userDir = os.path.dirname(os.environ["Userprofile"]) pList.cb_users.addItems([x for x in os.listdir(userDir) if x not in ["All Users", "Default", "Default User"] and os.path.isdir(os.path.join(userDir,x))]) pList.cb_users.setCurrentIndex(pList.cb_users.findText(user)) pList.cb_users.currentIndexChanged[str].connect(lambda x:refreshUI(pList, x)) pList.chb_shelves.toggled.connect(lambda x:refreshUI(pList, pList.cb_users.currentText())) pList.buttonBox.button(QDialogButtonBox.Ok).setText("Install") pList.buttonBox.button(QDialogButtonBox.Cancel).setFocusPolicy(Qt.NoFocus) pList.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True)) pList.setFocus() result = pList.exec_() if result == 0: print "Installation canceled" return False print "\n\nInstalling - please wait.." waitmsg = QMessageBox(QMessageBox.NoIcon, "Pandora Installation", "Installing - please wait..", QMessageBox.Cancel) waitmsg.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True)) waitmsg.setWindowIcon(wIcon) waitmsg.buttons()[0].setHidden(True) waitmsg.show() QCoreApplication.processEvents() lappdata = os.path.join(os.path.dirname(os.environ["Userprofile"]), pList.cb_users.currentText(), "AppData", "Local") appdata = os.path.join(os.path.dirname(os.environ["Userprofile"]), pList.cb_users.currentText(), "AppData", "Roaming") userFolders = {"LocalAppdata": lappdata, "AppData": appdata } pandoraFilesItem = pList.tw_components.findItems("Pandora files", Qt.MatchExactly)[0] keepSettingsItem = pandoraFilesItem.child(0) maxItem = mayaItem = houItem = bldItem = None if pList.chb_shelves.isChecked(): maxItem = pList.tw_components.findItems("3ds Max", Qt.MatchExactly | Qt.MatchRecursive)[0] mayaItem = pList.tw_components.findItems("Maya", Qt.MatchExactly | Qt.MatchRecursive)[0] houItem = pList.tw_components.findItems("Houdini", Qt.MatchExactly | Qt.MatchRecursive)[0] bldItem = pList.tw_components.findItems("Blender", Qt.MatchExactly | Qt.MatchRecursive)[0] result = {} settingsPath = userFolders["LocalAppdata"] + "\\Pandora\\Config\\Pandora.ini" settingsPathOld = userFolders["LocalAppdata"] + "\\Pandora\\Config\\PandoraOLD.ini" pandoraPath = userFolders["LocalAppdata"] + "\\Pandora\\" if pandoraFilesItem.checkState(0) == Qt.Checked: if keepSettingsItem.checkState(0) == Qt.Checked: if os.path.exists(settingsPath): sPath = settingsPath elif os.path.exists(settingsPathOld): sPath = settingsPathOld from ConfigParser import ConfigParser pconfig = ConfigParser() try: pconfig.read(sPath) except: os.remove(sPath) result["Pandora Files"] = copyfiles(pandoraPath, patch) if not result["Pandora Files"]: return result if keepSettingsItem.checkState(0) == Qt.Checked and "pconfig" in locals(): writeIni = True if not os.path.exists(os.path.dirname(settingsPathOld)): try: os.makedirs(os.path.dirname(settingsPathOld)) except: writeIni = False if writeIni: open(settingsPathOld, 'a').close() with open(settingsPathOld, 'w') as inifile: pconfig.write(inifile) installLocs = [] #max maxPaths = [] if maxItem is not None: for i in range(maxItem.childCount()): item = maxItem.child(i) if item.checkState(0) == Qt.Checked and os.path.exists(item.text(1)): maxPaths.append(item.text(1)) for i in maxPaths: result["3ds Max integration"] = writeMaxFiles(i) if result["3ds Max integration"]: installLocs.append(i) #maya mayaPaths = [] if mayaItem is not None: for i in range(mayaItem.childCount()): item = mayaItem.child(i) if item.checkState(0) == Qt.Checked and os.path.exists(item.text(1)): mayaPaths.append(item.text(1)) for i in mayaPaths: result["Maya integration"] = writeMayaFiles(i, userFolders) if result["Maya integration"]: installLocs.append(i) #houdini if houItem is not None: if houItem.checkState(0) == Qt.Checked and os.path.exists(houItem.text(1)): result["Houdini integration"] = writeHoudiniFiles(houItem.text(1)) if result["Houdini integration"]: installLocs.append(houItem.text(1)) # blender if bldItem is not None: if bldItem.checkState(0) == Qt.Checked and os.path.exists(bldItem.text(1)): result["Blender integration"] = writeBlenderFiles(bldItem.text(1)) if result["Blender integration"]: installLocs.append(bldItem.text(1)) if installLocs != []: locFile = pandoraPath + "installLocations.txt" locString = "" newLocs = [] if os.path.exists(locFile): with open(locFile, 'r') as locationfile: lines = locationfile.readlines() for loc in installLocs: for line in lines: if line.replace("\n", "") == loc: break else: newLocs.append(loc) else: open(locFile, 'w').close() newLocs = installLocs for i in newLocs: locString += i + "\n" with open(locFile, 'a') as locationfile: locationfile.write(locString) trayStartup = userFolders["AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\PandoraTray.lnk" trayStartMenu = userFolders["AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Pandora\\PandoraTray.lnk" handlerStartMenu = userFolders["AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Pandora\\PandoraRenderHandler.lnk" settingsStartMenu = userFolders["AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Pandora\\PandoraSettings.lnk" slaveStartMenu = userFolders["AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Pandora\\PandoraSlave.lnk" coordStartMenu = userFolders["AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Pandora\\PandoraCoordinator.lnk" if not os.path.exists(os.path.dirname(trayStartMenu)): try: os.makedirs(os.path.dirname(trayStartMenu)) except: pass if not os.path.exists(os.path.dirname(trayStartup)): try: os.makedirs(os.path.dirname(trayStartup)) except: pass if os.path.exists(trayStartup[:-3]+"lnk"): os.remove(trayStartup[:-3]+"lnk") trayLnk = os.path.join(userFolders["LocalAppdata"], "Pandora", "Tools", "PandoraTray.lnk") rhLnk = os.path.join(userFolders["LocalAppdata"], "Pandora", "Tools", "PandoraRenderHandler.lnk") settingsLnk = os.path.join(userFolders["LocalAppdata"], "Pandora", "Tools", "PandoraSettings.lnk") slaveLnk = os.path.join(userFolders["LocalAppdata"], "Pandora", "Tools", "PandoraSlave.lnk") coordLnk = os.path.join(userFolders["LocalAppdata"], "Pandora", "Tools", "PandoraCoordinator.lnk") if os.path.exists(trayLnk): if os.path.exists(os.path.dirname(trayStartup)): shutil.copy2(trayLnk, trayStartup) else: print "could not create PandoraTray autostart entry" if os.path.exists(os.path.dirname(trayStartMenu)): shutil.copy2(trayLnk, trayStartMenu) else: print "could not create PandoraTray startmenu entry" if os.path.exists(rhLnk) and os.path.exists(os.path.dirname(handlerStartMenu)): shutil.copy2(rhLnk, handlerStartMenu) else: print "could not create Pandora Render-Handler startmenu entry" if os.path.exists(settingsLnk) and os.path.exists(os.path.dirname(settingsStartMenu)): shutil.copy2(settingsLnk, settingsStartMenu) else: print "could not create Pandora settings startmenu entry" if os.path.exists(slaveLnk) and os.path.exists(os.path.dirname(slaveStartMenu)): shutil.copy2(slaveLnk, slaveStartMenu) else: print "could not create Pandora slave startmenu entry" if os.path.exists(coordLnk) and os.path.exists(os.path.dirname(coordStartMenu)): shutil.copy2(coordLnk, coordStartMenu) else: print "could not create Pandora coordinator startmenu entry" os.system('echo %s\\Pandora\\Tools\\PandoraTray.lnk | clip' % userFolders["LocalAppdata"]) if "waitmsg" in locals() and waitmsg.isVisible(): waitmsg.close() print "Finished" return result except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() msg = QMessageBox(QMessageBox.Warning, "Pandora Installation", "Errors occurred during the installation.\n The installation is possibly incomplete.\n\n%s\n%s\n%s" % (str(e), exc_type, exc_tb.tb_lineno), QMessageBox.Ok) msg.setFocus() msg.exec_() return False