Commit 11bcbc5d authored by Salgado M.V.I.'s avatar Salgado M.V.I.

Merge branch 'Tharindu/Rneder_Handler' into 'master'

Tharindu/rneder handler

See merge request !4
parents 9060828f 09f78028
This diff is collapsed.
This diff is collapsed.
import os, shutil, sys, imp, subprocess, csv, platform
if platform.system() == "Windows":
import _winreg, win32com
from win32com.shell import shellcon
import win32com.shell.shell as shell
import win32con, win32event, win32process
else:
import pwd
try:
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
psVersion = 2
except:
from PySide.QtCore import *
from PySide.QtGui import *
psVersion = 1
sys.path.append(os.path.join(os.path.dirname(__file__), "UserInterfacesPandora"))
if psVersion == 1:
import PandoraInstaller_ui
else:
import PandoraInstaller_ui_ps2 as PandoraInstaller_ui
from UserInterfacesPandora import qdarkstyle
class PandoraInstaller(QDialog, PandoraInstaller_ui.Ui_dlg_installer):
def __init__(self, core, uninstall=False):
QDialog.__init__(self)
self.core = core
pnames = self.core.getPluginNames()
self.plugins = {x:self.core.getPlugin(x) for x in pnames if x != "Standalone"}
if uninstall:
self.uninstall()
else:
self.setupUi(self)
try:
from win32com.shell import shell, shellcon
self.documents = shell.SHGetFolderPath(0, shellcon.CSIDL_PERSONAL, None, 0)
self.tw_components.header().resizeSection(0,200)
self.tw_components.itemDoubleClicked.connect(self.openBrowse)
self.refreshUI()
self.buttonBox.button(QDialogButtonBox.Ok).setText("Install")
self.buttonBox.accepted.connect(self.install)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
QMessageBox.warning(QWidget(), "Pandora Integration", "Errors occurred during the installation.\n\n%s\n%s\n%s" % (str(e), exc_type, exc_tb.tb_lineno))
def openBrowse(self, item, column):
if item.parent().text(0) != "DCC integrations" and item.text(0) not in ["Custom"] or item.childCount() > 0:
return
path = QFileDialog.getExistingDirectory(QWidget(), "Select destination folder", item.text(column))
if path != "":
item.setText(1, path)
item.setToolTip(1, path)
def CompItemClicked(self, item, column):
if item.text(0) in ["DCC integrations"] or item.childCount == 0:
return
isEnabled = item.checkState(0) == Qt.Checked
for i in range(item.childCount()):
if isEnabled:
if item.child(i).text(0) == "Custom" or item.child(i).text(1) != "":
item.child(i).setFlags(item.child(i).flags() | Qt.ItemIsEnabled)
else:
item.child(i).setFlags(~Qt.ItemIsEnabled)
def refreshUI(self):
try:
if platform.system() == "Windows":
userFolders = {"LocalAppdata": os.environ["localappdata"], "AppData": os.environ["appdata"], "UserProfile": os.environ["Userprofile"], "Documents":self.documents}
self.tw_components.clear()
self.tw_components.itemClicked.connect(self.CompItemClicked)
if len(self.plugins) > 0:
integrationsItem = QTreeWidgetItem(["DCC integrations"])
self.tw_components.addTopLevelItem(integrationsItem)
for i in sorted(self.plugins):
self.plugins[i].updateInstallerUI(userFolders, integrationsItem)
integrationsItem.setExpanded(True)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
msg = QMessageBox.warning(QWidget(), "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))
return False
def install(self):
try:
print "\n\nInstalling - please wait.."
dccItems = self.tw_components.findItems("DCC integrations", Qt.MatchExactly | Qt.MatchRecursive)
if len(dccItems) > 0:
dccItem = dccItems[0]
else:
dccItem = None
result = {}
if dccItem is not None:
for i in range(dccItem.childCount()):
childItem = dccItem.child(i)
if not childItem.text(0) in self.plugins:
continue
installPaths = self.plugins[childItem.text(0)].installerExecute(childItem, result)
if type(installPaths) == list:
for k in installPaths:
self.core.integrationAdded(childItem.text(0), k)
self.core.appPlugin.createWinStartMenu(self)
print "Finished"
if not False in result.values():
QMessageBox.warning(self.core.messageParent, "Pandora Installation", "Pandora was installed successfully.")
else:
msgString = "Some parts failed to install:\n\n"
for i in result:
msgString += "%s:\t\t%s\t\t\n\n" % (i, result[i])
msgString = msgString.replace("True", "Success").replace("False", "Error")
QMessageBox.warning(self.core.messageParent, "Pandora Installation", msgString)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
QMessageBox.warning(self.core.messageParent, "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))
return False
def removePandoraFiles(self):
try:
try:
import psutil
except:
pass
else:
PROCNAMES = ['PandoraTray.exe', 'PandoraRenderHandler.exe', 'PandoraSettings.exe', 'PandoraSlave.exe', "PandoraCoordinator.exe"]
for proc in psutil.process_iter():
if proc.name() in PROCNAMES:
p = psutil.Process(proc.pid)
try:
if not 'SYSTEM' in p.username():
proc.kill()
print "closed Pandora process"
except:
pass
smPath = os.path.join(os.environ["appdata"], "Microsoft", "Windows", "Start Menu", "Programs")
smTray = os.path.join(smPath, "Pandora", "PandoraTray.lnk")
smHandler = os.path.join(smPath, "Pandora", "PandoraRenderHandler.lnk")
smSettings = os.path.join(smPath, "Pandora", "PandoraSettings.lnk")
smSlave = os.path.join(smPath, "Pandora", "PandoraSlave.lnk")
smCoordinator = os.path.join(smPath, "Pandora", "PandoraCoordinator.lnk")
suTray = os.path.join(smPath, "Startup", "PandoraTray.lnk")
for i in [smTray, smHandler, smSettings, smSlave, smCoordinator, suTray]:
if os.path.exists(i):
try:
os.remove(i)
except:
pass
smFolder = os.path.dirname(smTray)
try:
shutil.rmtree(smFolder)
except:
pass
return True
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
QMessageBox.warning(self.core.messageParent, "Pandora Uninstallation", "Error occurred during Pandora files removal:\n\n%s\n%s\n%s" % (str(e), exc_type, exc_tb.tb_lineno))
return False
def uninstall(self):
msg = QMessageBox(QMessageBox.Question, "Pandora Render Manager", "Are you sure you want to uninstall Pandora?\n\nThis will delete all Pandora integrations from your PC. Your renderings and scenefiles will remain unaffected.", QMessageBox.Cancel, parent=self.core.messageParent)
msg.addButton("Continue", QMessageBox.YesRole)
action = msg.exec_()
if action != 0:
return False
print "uninstalling..."
result = {}
if os.path.exists(self.core.installLocPath):
cData = self.core.getConfig(configPath=self.core.installLocPath, getConf=True)
for i in cData:
if not i in self.plugins:
continue
appPaths = cData[i]
for k in cData[i]:
result["%s integration" % i] = self.plugins[i].removeIntegration(cData[i][k])
result["Pandora Files"] = self.removePandoraFiles()
if not False in result.values():
msgStr = "All Pandora integrations were removed successfully. To finish the uninstallation delete the Pandora folder:\n\n%s" % self.core.pandoraRoot
QMessageBox.information(self.core.messageParent, "Pandora Uninstallation", msgStr)
else:
msgString = "Some parts failed to uninstall:\n\n"
for i in result:
msgString += "%s:\t\t%s\t\t\n\n" % (i, result[i])
msgString = msgString.replace("True", "Success").replace("False", "Error").replace("Pandora Files:", "Pandora Files:\t")
QMessageBox.warning(self.core.messageParent, "Pandora Installation", msgString)
sys.exit()
def force_elevated():
try:
if sys.argv[-1] != 'asadmin':
script = os.path.abspath(sys.argv[0])
params = ' '.join(["\"%s\"" % script] + sys.argv[1:] + ['asadmin'])
procInfo = shell.ShellExecuteEx(nShow=win32con.SW_SHOWNORMAL,
fMask=shellcon.SEE_MASK_NOCLOSEPROCESS,
lpVerb='runas',
lpFile=sys.executable,
lpParameters=params)
procHandle = procInfo['hProcess']
obj = win32event.WaitForSingleObject(procHandle, win32event.INFINITE)
rc = win32process.GetExitCodeProcess(procHandle)
sys.exit()
except Exception as ex:
print ex
if __name__ == "__main__":
qApp = QApplication(sys.argv)
wIcon = QIcon(os.path.join(os.path.dirname(os.path.abspath(__file__)), "UserInterfacesPandora", "pandora_tray.png"))
qApp.setWindowIcon(wIcon)
qApp.setStyleSheet(qdarkstyle.load_stylesheet(pyside=True))
if sys.argv[-1] != 'asadmin':
force_elevated()
else:
import PandoraCore
pc = PandoraCore.PandoraCore()
if sys.argv[-2] == "uninstall":
pc.openInstaller(uninstall=True)
else:
pc.openInstaller()
sys.exit(qApp.exec_())
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
try:
from PySide.QtCore import *
from PySide.QtGui import *
psVersion = 1
except:
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
psVersion = 2
import sys, os, traceback, time, socket
from functools import wraps
sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "UserInterfacesPandora"))
try:
del sys.modules["PandoraSlaveAssignment_ui"]
except:
pass
if psVersion == 1:
import PandoraSlaveAssignment_ui
else:
import PandoraSlaveAssignment_ui_ps2 as PandoraSlaveAssignment_ui
class PandoraSlaveAssignment(QDialog, PandoraSlaveAssignment_ui.Ui_dlg_SlaveAssignment):
def __init__(self, core, curSlaves=""):
QDialog.__init__(self)
self.setupUi(self)
self.core = core
self.core.parentWindow(self)
self.slaveGroups = []
self.activeGroups = []
self.getSlaves()
self.connectEvents()
if curSlaves.startswith("exclude "):
self.rb_exclude.setChecked(True)
curSlaves = curSlaves[len("exclude "):]
if curSlaves == "All":
self.rb_all.setChecked(True)
self.lw_slaves.selectAll()
elif curSlaves.startswith("groups: "):
groupList = curSlaves[len("groups: "):].split(", ")
for i in self.slaveGroups:
if i.text() in groupList:
i.setChecked(True)
self.rb_group.setChecked(True)
elif curSlaves != "":
slaveList = curSlaves.split(", ")
for i in range(self.lw_slaves.count()):
item = self.lw_slaves.item(i)
if item.text() in slaveList:
self.lw_slaves.setCurrentItem(item, QItemSelectionModel.Select)
self.rb_custom.setChecked(True)
else:
self.rb_custom.setChecked(True)
def err_decorator(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except Exception as e:
exc_type, exc_obj, exc_tb = sys.exc_info()
erStr = ("%s ERROR - PandoraSlaveAssignment %s:\n%s\n\n%s" % (time.strftime("%d/%m/%y %X"), args[0].core.version, ''.join(traceback.format_stack()), traceback.format_exc()))
args[0].core.writeErrorLog(erStr)
return func_wrapper
@err_decorator
def connectEvents(self):
self.lw_slaves.itemSelectionChanged.connect(self.selectionChanged)
self.lw_slaves.itemDoubleClicked.connect(self.accept)
self.rb_all.clicked.connect(lambda: self.optionChanged("all"))
self.rb_group.clicked.connect(lambda: self.optionChanged("group"))
self.rb_custom.clicked.connect(lambda: self.optionChanged("custom"))
@err_decorator
def getSlaves(self):
self.lw_slaves.clear()
slaveData = self.core.getSlaveData()
gLayout = QVBoxLayout()
self.w_slaveGroups.setLayout(gLayout)
for i in slaveData["slaveNames"]:
sItem = QListWidgetItem(i)
self.lw_slaves.addItem(sItem)
for i in slaveData["slaveGroups"]:
chbGroup = QCheckBox(i)
chbGroup.toggled.connect(self.groupToogled)
gLayout.addWidget(chbGroup)
self.slaveGroups.append(chbGroup)
@err_decorator
def selectionChanged(self):
if len(self.lw_slaves.selectedItems()) == self.lw_slaves.count() and self.rb_all.isChecked():
return
self.rb_custom.setChecked(True)
@err_decorator
def optionChanged(self, option):
if option == "all":
self.lw_slaves.selectAll()
elif option == "group":
self.selectGroups()
@err_decorator
def groupToogled(self, checked=False):
self.activeGroups = []
for i in self.slaveGroups:
if i.isChecked():
self.activeGroups.append(i.text())
if len(self.activeGroups) > 0:
self.selectGroups()
else:
self.lw_slaves.clearSelection()
self.rb_group.setChecked(True)
@err_decorator
def selectGroups(self):
self.lw_slaves.clearSelection()
if len(self.activeGroups) > 0:
for i in range(self.lw_slaves.count()):
sGroups = self.lw_slaves.item(i).toolTip().split(", ")
for k in self.activeGroups:
if k not in sGroups:
break
else:
self.lw_slaves.setCurrentRow(i, QItemSelectionModel.Select)
self.rb_group.setChecked(True)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Pandora/Setup_Integrations.bat
Pandora/Setup_Startmenu.bat
\ No newline at end of file
start Python27/pythonw.exe Scripts/PandoraInstaller.py
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment