def __init__(self): QMainWindow.__init__(self) self.setupUi(self) #Class Variables self.thisNodeName = Utils.myHostName() logger.info("This host is %s", self.thisNodeName) self.username = Utils.getInfoFromCFG("database", "username") self.userFilter = False self.showArchivedFilter = False self.statusMsg = "ERROR" self.currentJobSel = None with open(Utils.findResource("styleSheet.css"), "r") as myStyles: self.setStyleSheet(myStyles.read()) #My UI Setup Functions self.setupTreeViews() self.connectButtons() self.setupHotkeys() self.setWindowIcon(QIcon(Utils.findResource("Images/FarmView.png"))) #Make sure this node exists self.thisNodeButtonsEnabled = True self.thisNodeExists = self.findThisNode() #Setup Signals SIGNAL("doUpdate") QObject.connect(self, SIGNAL("doUpdate"), self.doUpdate) #Start autoUpdater and then fetch data from DB self.autoUpdateThread = stoppableThread(self.doUpdateSignaler, 10, "AutoUpdate_Thread") self.doFetch()
def __init__(self): QMainWindow.__init__(self) self.setupUi(self) with open(Utils.findResource("styleSheet.css"), "r") as myStyles: self.setStyleSheet(myStyles.read()) self.thisNode = NodeUtils.getThisNodeOBJ() self.isVisable = True self.pulseThreadStatus = False self.renderServerStatus = False self.schedThreadStatus = False self.autoUpdateStatus = False if not self.thisNode: self.offlineButton.setEnabled(False) self.getoffButton.setEnabled(False) logger.error("Node does not exist in database!") aboutBox(self, "Error", "This node was not found in the database! If you wish to render " "on this node it must be registered with the databse. Run " "Register.exe or Register.py to regiester this node and " " try again.") sys.exit(1) self.currentSchedule = self.thisNode.weekSchedule self.currentScheduleEnabled = self.thisNode.scheduleEnabled self.buildUI() self.connectButtons() self.updateThisNodeInfo() self.startupServers() logger.info("Render Node Main is live! Waiting for tasks...") try: autoHide = True if str(sys.argv[1]).lower() == "true" else False logger.info(autoHide) except IndexError: autoHide = False if autoHide and self.trayIconBool: logger.info("Autohide is enabled!") self.sendToTrayHandler() else: self.show()
def buildUI(self): def addItem(name, handler, statusTip, menu): action = QAction(name, self) action.setStatusTip(statusTip) action.triggered.connect(handler) menu.addAction(action) #Add Logging handlers for output field emStream = EmittingStream(textWritten=self.normalOutputWritten) handler = logging.StreamHandler(emStream) handler.setLevel(logging.INFO) handler.setFormatter(outputWindowFormatter) logger.addHandler(handler) sys.stdout = EmittingStream(textWritten=self.normalOutputWritten) sys.stderr = EmittingStream(textWritten=self.normalOutputWritten) #Get Pixmaps and Icon self.donePixmap = QPixmap(Utils.findResource("Images/status/done.png")) self.inProgPixmap = QPixmap(Utils.findResource("Images/status/inProgress.png")) self.needsAttentionPixmap = QPixmap(Utils.findResource("Images/status/needsAttention.png")) self.nonePixmap = QPixmap(Utils.findResource("Images/status/none.png")) self.notStartedPixmap = QPixmap(Utils.findResource("Images/status/notStarted.png")) self.refreshPixmap = QPixmap(Utils.findResource("Images/refresh.png")) self.refreshIcon = QIcon() self.refreshIcon.addPixmap(self.refreshPixmap) self.RIcon = QIcon(Utils.findResource("Images/RenderNodeMain.png")) self.isVisable = True self.refreshButton.setIcon(self.refreshIcon) self.renderServerPixmap.setPixmap(self.notStartedPixmap) self.scheduleThreadPixmap.setPixmap(self.notStartedPixmap) self.pulseThreadPixmap.setPixmap(self.notStartedPixmap) self.setWindowIcon(self.RIcon) #Setup tray icon self.trayIcon = QSystemTrayIcon() self.trayIconBool = self.trayIcon.isSystemTrayAvailable() if self.trayIconBool: self.trayIcon.setIcon(self.RIcon) self.trayIcon.show() self.trayIcon.setVisible(True) self.trayIcon.activated.connect(self.activate) self.trayIcon.messageClicked.connect(self.activate) #Tray Icon Context Menu self.taskIconMenu = QMenu(self) addItem("Open", self.showWindowHandler, "Show the RenderNodeMain Window", self.taskIconMenu) self.taskIconMenu.addSeparator() addItem("Update", self.updateThisNodeInfo, "Fetch the latest information from the Database", self.taskIconMenu) self.taskIconMenu.addSeparator() addItem("Online", self.onlineThisNodeHandler, "Online this node", self.taskIconMenu) addItem("Offline", self.offlineThisNodeHandler, "Offline this node", self.taskIconMenu) addItem("GetOff!", self.getOffThisNodeHandler, "Kill the current task and offline this node", self.taskIconMenu) self.trayIcon.setContextMenu(self.taskIconMenu) else: logger.error("Tray Icon Error! Could not create tray icon.") aboutBox(self, "Tray Icon Error", "Could not create tray icon. Minimizing to tray has been disabled.") self.trayButton.setEnabled(False)