else: pc.openInstaller() except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() QMessageBox.warning(QWidget(), "Prism 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)) if __name__ == "__main__": qApp = QApplication(sys.argv) try: wIcon = QIcon(os.path.join(os.path.dirname(os.path.abspath(__file__)), "UserInterfacesPrism", "p_tray.png")) qApp.setWindowIcon(wIcon) qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True)) if platform.system() == "Windows": startInstaller_Windows() elif platform.system() == "Linux": startInstaller_Linux() elif platform.system() == "Darwin": startInstaller_Mac() except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() QMessageBox.warning(QWidget(), "Prism Installation", "Errors occurred.\n\n%s\n%s\n%s" % (str(e), exc_type, exc_tb.tb_lineno)) sys.exit(qApp.exec_())
def install(self, patch=False, documents=""): try: pList = InstallList.InstallList() pList.setModal(True) pList.tw_components.header().resizeSection(0, 200) pList.tw_components.itemDoubleClicked.connect(self.openBrowse) self.refreshUI(pList, self.exUser, documents=documents) if platform.system() == "Windows": 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(self.exUser)) pList.cb_users.currentIndexChanged[str].connect( lambda x: self.refreshUI(pList, x, documents=documents)) else: pList.widget.setVisible(False) 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, "Prism 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() if platform.system() == "Windows": 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, "Documents": documents } settingsPath = userFolders[ "LocalAppdata"] + "\\Prism\\Prism.ini" settingsPathOld = userFolders[ "LocalAppdata"] + "\\Prism\\PrismOLD.ini" prismPath = userFolders["LocalAppdata"] + "\\Prism\\" elif platform.system() == "Linux": userFolders = {} settingsPath = "/usr/local/Prism/Prism.ini" settingsPathOld = "/usr/local/Prism/PrismOLD.ini" prismPath = "/usr/local/Prism" elif platform.system() == "Darwin": userFolders = {} settingsPath = "/Applications/Prism/Prism/Prism.ini" settingsPathOld = "/Applications/Prism/Prism/PrismOLD.ini" prismPath = "/Applications/Prism/Prism" prismFilesItem = pList.tw_components.findItems( "Prism files", Qt.MatchExactly)[0] keepSettingsItem = prismFilesItem.child(0) dccItems = pList.tw_components.findItems( "DCC integrations", Qt.MatchExactly | Qt.MatchRecursive) if len(dccItems) > 0: dccItem = dccItems[0] else: dccItem = None result = {} if prismFilesItem.checkState(0) == Qt.Checked: if keepSettingsItem.checkState(0) == Qt.Checked: if os.path.exists(settingsPath): sPath = settingsPath elif os.path.exists(settingsPathOld): sPath = settingsPathOld pconfig = ConfigParser() try: pconfig.read(sPath) except: os.remove(sPath) result["Prism Files"] = self.copyfiles(prismPath, patch) if not result["Prism 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) if platform.system() in ["Linux", "Darwin"]: os.chmod(settingsPathOld, 0o777) installLocs = {} locFile = os.path.join(prismPath, "installLocations.ini") if dccItem is not None: for i in range(dccItem.childCount()): childItem = dccItem.child(i) if not childItem.text(0) in self.prismPlugins: continue installLocs[childItem.text(0)] = self.prismPlugins[ childItem.text(0)].installerExecute( childItem, result, locFile) if len(installLocs) > 0: locConfig = ConfigParser() if os.path.exists(locFile): try: locConfig.read(locFile) except: pass for i in installLocs: existingItems = [] if locConfig.has_section(i): existingItems = locConfig.items(i) else: locConfig.add_section(i) paths = installLocs[i] if type(paths) != list: continue for path in paths: if path not in [x[1] for x in existingItems]: locConfig.set(i, "%02d" % (len(existingItems) + 1), path) with open(locFile, 'w') as inifile: locConfig.write(inifile) if platform.system() == "Windows": # setting regestry keys for wand module (EXR preview in Blender and Nuke) curkey = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\ImageMagick\Current") _winreg.SetValueEx(curkey, "Version", 0, _winreg.REG_SZ, "6.9.9") key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\ImageMagick\6.9.9\Q:16") _winreg.SetValueEx( key, "LibPath", 0, _winreg.REG_SZ, os.path.join(userFolders["LocalAppdata"], "Prism", "Tools", "ImageMagick-6.9.9-Q16")) _winreg.SetValueEx( key, "CoderModulesPath", 0, _winreg.REG_SZ, os.path.join(userFolders["LocalAppdata"], "Prism", "Tools", "ImageMagick-6.9.9-Q16", "modules", "coders")) _winreg.SetValueEx( key, "FilterModulesPath", 0, _winreg.REG_SZ, os.path.join(userFolders["LocalAppdata"], "Prism", "Tools", "ImageMagick-6.9.9-Q16", "modules", "filters")) key.Close() curkey.Close() trayStartup = userFolders[ "AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\PrismTray.lnk" trayStartMenu = userFolders[ "AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Prism\\PrismTray.lnk" pbStartMenu = userFolders[ "AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Prism\\PrismProjectBrowser.lnk" settingsStartMenu = userFolders[ "AppData"] + "\\Microsoft\\Windows\\Start Menu\\Programs\\Prism\\PrismSettings.lnk" trayLnk = os.path.join(userFolders["LocalAppdata"], "Prism", "Tools", "PrismTray.lnk") pbLnk = os.path.join(userFolders["LocalAppdata"], "Prism", "Tools", "PrismProjectBrowser.lnk") settingsLnk = os.path.join(userFolders["LocalAppdata"], "Prism", "Tools", "PrismSettings.lnk") cbPath = trayStartup elif platform.system() == "Linux": if os.path.exists(locFile): os.chmod(locFile, 0o777) trayStartup = "/etc/xdg/autostart/PrismTray.desktop" trayStartMenu = "/usr/share/applications/PrismTray.desktop" pbStartMenu = "/usr/share/applications/PrismProjectBrowser.desktop" settingsStartMenu = "/usr/share/applications/PrismSettings.desktop" trayLnk = "/usr/local/Prism/Tools/PrismTray.desktop" pbLnk = "/usr/local/Prism/Tools/PrismProjectBrowser.desktop" settingsLnk = "/usr/local/Prism/Tools/PrismSettings.desktop" cbPath = "/usr/local/Prism/Tools/PrismTray.sh" pMenuSource = "/usr/local/Prism/Tools/Prism.menu" pMenuTarget = "/etc/xdg/menus/applications-merged/Prism.menu" if not os.path.exists(os.path.dirname(pMenuTarget)): try: os.makedirs(os.path.dirname(pMenuTarget)) except: pass if os.path.exists(pMenuTarget): os.remove(pMenuTarget) if os.path.exists(pMenuSource) and os.path.exists( os.path.dirname(pMenuTarget)): shutil.copy2(pMenuSource, pMenuTarget) else: print "could not create Prism startmenu entry" if os.path.exists(pbLnk): userName = os.environ[ 'SUDO_USER'] if 'SUDO_USER' in os.environ else os.environ[ 'USER'] desktopPath = "/home/%s/Desktop/%s" % ( userName, os.path.basename(pbLnk)) if os.path.exists(desktopPath): try: os.remove(desktopPath) except: pass if os.path.exists(os.path.dirname(desktopPath)): shutil.copy2(pbLnk, desktopPath) uid = pwd.getpwnam(userName).pw_uid os.chown(desktopPath, uid, -1) #subprocess.Popen(['bash', "/usr/local/Prism/Tools/PrismTray.sh"]) elif platform.system() == "Darwin": if os.path.exists(locFile): os.chmod(locFile, 0o777) userName = os.environ[ 'SUDO_USER'] if 'SUDO_USER' in os.environ else os.environ[ 'USER'] trayStartup = "/Users/%s/Library/LaunchAgents/com.user.PrismTray.plist" % userName trayStartMenu = "/Applications/Prism/Prism Tray.app" pbStartMenu = "/Applications/Prism/Prism Project Browser.app" settingsStartMenu = "/Applications/Prism/Prism Settings.app" trayStartupSrc = "/Applications/Prism/Prism/Tools/com.user.PrismTray.plist" trayLnk = "/Applications/Prism/Prism/Tools/Prism Tray.app" pbLnk = "/Applications/Prism/Prism/Tools/Prism Project Browser.app" settingsLnk = "/Applications/Prism/Prism/Tools/Prism Settings.app" cbPath = "/Applications/Prism/Prism/Tools/PrismTray.sh" if os.path.exists(pbLnk): desktopPath = "/Users/%s/Desktop/%s" % ( userName, os.path.splitext(os.path.basename(pbLnk))[0]) if os.path.exists(desktopPath): try: os.remove(desktopPath) except: pass os.symlink(pbLnk, desktopPath) #subprocess.Popen(['bash', "/usr/local/Prism/Tools/PrismTray.sh"]) if trayStartMenu != "" and 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)) if platform.system() in ["Linux", "Darwin"]: os.chmod(os.path.dirname(trayStartup), 0o777) except: pass if os.path.exists(trayStartup): os.remove(trayStartup) if os.path.exists(trayLnk): if os.path.exists(os.path.dirname(trayStartup)): if platform.system() == "Darwin": if os.path.exists(trayStartupSrc): shutil.copy2(trayStartupSrc, trayStartup) os.chmod(trayStartup, 0o644) uid = pwd.getpwnam(userName).pw_uid os.chown(os.path.dirname(trayStartup), uid, -1) os.chown(trayStartup, uid, -1) # os.system("launchctl load /Users/%s/Library/LaunchAgents/com.PrismTray.plist" % userName) else: shutil.copy2(trayLnk, trayStartup) else: print "could not create PrismTray autostart entry" if trayStartMenu != "": if os.path.exists(os.path.dirname(trayStartMenu)): if os.path.isdir(trayLnk): if os.path.exists(trayStartMenu): shutil.rmtree(trayStartMenu) shutil.copytree(trayLnk, trayStartMenu) else: shutil.copy2(trayLnk, trayStartMenu) else: print "could not create PrismTray startmenu entry" if pbStartMenu != "": if os.path.exists(pbLnk) and os.path.exists( os.path.dirname(pbStartMenu)): if os.path.isdir(pbLnk): if os.path.exists(pbStartMenu): shutil.rmtree(pbStartMenu) shutil.copytree(pbLnk, pbStartMenu) else: shutil.copy2(pbLnk, pbStartMenu) else: print "could not create PrismProjectBrowser startmenu entry" if settingsStartMenu != "": if os.path.exists(settingsLnk) and os.path.exists( os.path.dirname(settingsStartMenu)): if os.path.isdir(settingsLnk): if os.path.exists(settingsStartMenu): shutil.rmtree(settingsStartMenu) shutil.copytree(settingsLnk, settingsStartMenu) else: shutil.copy2(settingsLnk, settingsStartMenu) else: print "could not create PrismSettings startmenu entry" cb = qApp.clipboard() cb.setText(trayLnk) 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, "Prism 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