Ejemplo n.º 1
0
    def execute(self, proc, *args, **kargs):
        rc = None
        frame = adm.StartWaiting()
        try:
            rc = proc(*args, **kargs)
        except Exception as e:
            d = e[0]
            adm.StopWaiting(frame, d)
            raise e

        adm.StopWaiting(frame)
        return rc
Ejemplo n.º 2
0
    def Send(self, updater):
        frame = adm.StartWaiting()
        try:
            result = self.connection.Send(updater)
        except Exception as e:
            txt = xlt("Couldn't send data: %s %s " %
                      (e.__class__.__name__, str(e)))
            adm.StopWaiting(frame, txt)
            raise adm.ServerException(self, txt)

        adm.StopWaiting(frame)
        return result
Ejemplo n.º 3
0
    def GetZone(self, zone):
        frame = adm.StartWaiting()
        try:
            z = self.connection.GetZone(zone)
        except Exception as e:
            txt = xlt("Couldn't Transfer zone data for %s: %s %s " %
                      (zone, e.__class__.__name__, str(e)))
            adm.StopWaiting(frame, txt)
            raise adm.ServerException(self, txt)

        adm.StopWaiting(frame)
        return z
Ejemplo n.º 4
0
 def ExecuteSet(self, cmd, args=None):
     frame = adm.StartWaiting()
     try:
         self.execute(cmd, args)
         self.wait("ExecuteSet")
         rowset = pgRowset(self)
         logger.querylog(self.cursor.query,
                         result="%d rows" % rowset.GetRowcount())
         adm.StopWaiting(frame)
         return rowset
     except Exception as e:
         adm.StopWaiting(frame, e.error)
         raise e
Ejemplo n.º 5
0
    def Execute(self, cmd, args=None, spot=None):
        frame = adm.StartWaiting()
        try:
            self.execute(cmd, args)
            self.wait("Execute")
            adm.StopWaiting(frame)
        except Exception as e:
            adm.StopWaiting(frame, e)
            raise e
        rc = self.GetRowcount()
        if spot: spot += " "
        else: spot = ""

        logger.querylog(self.cursor.query, result=spot + xlt("%d rows") % rc)
        return rc
Ejemplo n.º 6
0
    def ExecuteRow(self, cmd, args=None):
        frame = adm.StartWaiting()
        try:
            self.execute(cmd, args)
            self.wait("ExecuteRow")
            row = self.cursor.fetchone()
            adm.StopWaiting(frame)
        except Exception as e:
            adm.StopWaiting(frame, e)
            raise e

        if row:
            row = pgRow(self, row)
            logger.querylog(self.cursor.query, result=unicode(row))
            return row
        return None
Ejemplo n.º 7
0
 def ExecuteSingle(self, cmd, args=None):
     frame = adm.StartWaiting()
     try:
         self.execute(cmd, args)
         self.wait("ExecuteSingle")
         try:
             row = self.cursor.fetchone()
         except Exception as _e:
             #print e
             row = None
         adm.StopWaiting(frame)
     except Exception as e:
         adm.StopWaiting(frame, e)
         raise e
     if row:
         result = row[0]
         logger.querylog(self.cursor.query, result="%s" % result)
         return result
     else:
         logger.querylog(self.cursor.query, result=xlt("no result"))
         return None
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
    def _handleException(self, exception):
        if self.cursor and self.cursor.query:
            cmd = self.cursor.query
        else:
            cmd = None

        exception.message = errlines = exception.message.decode('utf8')
        logger.querylog(cmd, error=errlines)

        if self.trapSqlException:
            self.lastError = errlines
            if self.pool:
                self.pool.lastError = errlines

        adm.StopWaiting(adm.mainframe)
        if self.conn and self.conn.closed:
            self.disconnect()
        if self.trapSqlException:
            raise SqlException(cmd, errlines)
        else:
            raise exception
Ejemplo n.º 11
0
    def ConnectServer(self, server, treename):
        if not server.IsConnected(True):
            rc = False
            frame = adm.StartWaiting(
                xlt("Connecting to %(type)s %(name)s...") % {
                    "type": server.typename,
                    "name": server.name
                }, True)
            server.properties = []
            try:
                rc = server.Connect(self)
            except adm.ConnectionException as _e:
                adm.StopWaiting(frame, xlt("Not connected"))
                return False

            if not rc:
                adm.StopWaiting(frame, xlt("Not connected"))
                if rc != None:
                    wx.MessageBox(
                        xlt("Connect failed."),
                        xlt("%(type)s %(name)s") % {
                            "type": server.typename,
                            "name": server.name
                        })
                return rc

            adm.StopWaiting(frame, xlt("connected."))
            server.registrationChanged = False

        tree = adm.trees.get(treename)
        if tree:
            item = tree.Find(None, server, 1)
            if not item:
                item = tree.Append(None, server)
        else:
            from frame import DetailFrame
            _frame = DetailFrame(self, treename)  # IGNORE
            tree = adm.trees[treename]
            item = tree.Append(None, server)

        if server.settings.get('rememberLastNode', True):
            nodePath = server.settings.get('nodePath')
            if nodePath:
                for nodeId in nodePath.split('/'):
                    type, name = nodeId.split(':')
                    id = adm.NodeId(type, name)
                    if id == server.id:
                        continue
                    tree.Expand(item)
                    found = False
                    for item in tree.GetChildItems(item):
                        node = tree.GetNode(item)
                        if node.id == id:
                            found = True
                            break
                    if not found:
                        break

        tree.SelectItem(item)
        tree.EnsureVisible(item)
        tree.SetFocus()

        return True