def ShowQueryTool(parent, server, line): from QueryTool import QueryFrame params = { 'dbname': line[LoggingPage.getIndex('database_name')], 'query': line[LoggingPage.getIndex('query')], 'errline': line[LoggingPage.getIndex('query_pos')], 'message': line[LoggingPage.getIndex('message')], 'hint': line[LoggingPage.getIndex('hint')] } frame = QueryFrame(adm.GetCurrentFrame(parent), server, params) return frame
def OnLoglineRightClick(self, evt): cm = Menu(adm.GetCurrentFrame(self)) sel = self.control.GetSelection() if not sel: sel = [evt.GetIndex()] self.control.SetSelection(sel) cm.Add(self.OnCopy, xlt("Copy"), xlt("Copy line to clipboard")) q = self.log[sel[0]][self.getIndex('query')] if q: cm.Add(self.OnQuery, xlt("Query"), xlt("Execute query")) cm.Add(self.OnLoglinesDclick, xlt("Details"), xlt("Show details")) cm.Popup(evt)
def raiseException(self, e, what): if isinstance(e.args[0], dict): info = e.args[0].get('info') if not info: info = e.args[0].get('desc') if not info: info = "Exception: %s" % str(e) else: info = "%s failed. %s - %s" % (what, type(e).__name__, str(e)) fr = adm.GetCurrentFrame() if fr: adm.StopWaiting(fr, "LDAP Error: %s" % info) raise adm.ServerException(self.node, info)
def CheckConnection(self, connection): if not connection or connection.HasFailed(): if connection and hasattr(connection, 'lastError'): err = connection.lastError else: err = "" if hasattr(self, 'waitingFrame'): frame = self.waitingFrame if frame: adm.StopWaiting(frame) else: frame = adm.GetCurrentFrame() if frame: frame.SetStatus(xlt("disconnected: %s") % err) raise adm.NoConnectionException(self, None)
def Delete(self): if not 'x' in self.myrights and not 'c' in self.myrights: dlg = wx.MessageDialog( adm.GetCurrentFrame(), xlt("Add missing right and delete?"), xlt("Missing rights on mailbox %s") % self.name, wx.YES_NO | wx.NO_DEFAULT) if dlg.ShowModal() != wx.ID_YES: return False rc = self.GetConnection().SetAcl(self.mailboxPath, self.GetServer().user, self.myrights + 'xcd') if not rc: return False rc = self.GetConnection().DeleteMailbox(self.mailboxPath) return rc != None
def OnItemRightClick(self, evt): if self.node: if hasattr(evt, 'GetIndex'): index = evt.GetIndex() else: index = -1 page = self.pages[self.GetSelection()] if not hasattr(evt, 'page'): evt.page = page if hasattr(page, 'menus'): cm = Menu(self) menus = page.menus for cls in menus: if hasattr(cls, "CheckAvailableOn" ) and not cls.CheckAvailableOn(page): continue cls.OnExecute._classname_ = cls.__name__ item = cm.Add(cls.OnExecute, cls.name, cls.help) if hasattr(cls, "CheckEnabled") and not cls.CheckEnabled(page): cm.Enable(item, False) if cm.GetMenuItemCount(): cm.Popup(evt) elif hasattr(self.node, "OnItemRightClick"): evt.currentPage = page self.node.OnItemRightClick(evt) elif hasattr(self.node, "GetItemNode"): node = self.node.GetItemNode(evt.page, index) if node: node.RefreshVolatile() node.GetProperties() w = adm.GetCurrentFrame(self) cm = w.GetContextMenu(node) w.currentNode = node cm.Popup(evt) w.currentNode = None