[rhmessaging-commits] rhmessaging commits: r3790 - in mgmt/trunk: mint/python/mint and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Jan 12 16:47:25 EST 2010


Author: justi9
Date: 2010-01-12 16:47:25 -0500 (Tue, 12 Jan 2010)
New Revision: 3790

Modified:
   mgmt/trunk/cumin/python/cumin/model.py
   mgmt/trunk/cumin/python/cumin/test.py
   mgmt/trunk/mint/python/mint/database.py
   mgmt/trunk/mint/python/mint/expire.py
   mgmt/trunk/mint/python/mint/main.py
   mgmt/trunk/mint/python/mint/model.py
   mgmt/trunk/mint/python/mint/schema.py
   mgmt/trunk/mint/python/mint/schemalocal.py
   mgmt/trunk/mint/python/mint/schemaparser.py
   mgmt/trunk/mint/python/mint/sql.py
   mgmt/trunk/mint/python/mint/tools.py
   mgmt/trunk/mint/python/mint/update.py
   mgmt/trunk/mint/python/mint/util.py
   mgmt/trunk/mint/python/mint/vacuum.py
Log:
Four-space tabs, and pythonic naming

Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/cumin/python/cumin/model.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -25,9 +25,9 @@
         config = app.config
 
         self.mint = Mint(config)
-        self.mint.updateEnabled = False
-        self.mint.expireEnabled = False
-        self.mint.vacuumEnabled = False
+        self.mint.update_enabled = False
+        self.mint.expire_enabled = False
+        self.mint.vacuum_enabled = False
 
         self.lock = Lock()
 

Modified: mgmt/trunk/cumin/python/cumin/test.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/test.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/cumin/python/cumin/test.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -24,7 +24,7 @@
         log.info("Waiting for the broker to connect")
 
         def connect():
-            if self.app.model.mint.model.isConnected():
+            if self.app.model.mint.model.agents:
                 log.info("The broker is connected")
                 return True
 
@@ -36,7 +36,7 @@
         self.user = Subject.getByName("tester")
 
         if not self.user:
-            self.user = Subject(name="tester")
+            self.user = Subject(name="tester", password="XXX")
             self.user.syncUpdate()
 
         super(CuminTest, self).do_run(session)

Modified: mgmt/trunk/mint/python/mint/database.py
===================================================================
--- mgmt/trunk/mint/python/mint/database.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/database.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -9,153 +9,153 @@
 log = logging.getLogger("mint.database")
 
 class MintDatabase(object):
-  def __init__(self, app):
-    self.app = app
+    def __init__(self, app):
+        self.app = app
 
-  def getConnection(self):
-    return connectionForURI(self.app.config.data).getConnection()
+    def get_connection(self):
+        return connectionForURI(self.app.config.data).getConnection()
 
-  def check(self):
-    self.checkConnection()
+    def check(self):
+        self.check_connection()
 
-  def init(self):
-    sqlhub.processConnection = connectionForURI(self.app.config.data)
+    def init(self):
+        sqlhub.processConnection = connectionForURI(self.app.config.data)
 
-  def checkConnection(self):
-    conn = self.getConnection()
+    def check_connection(self):
+        conn = self.get_connection()
 
-    try:
-      cursor = conn.cursor()
-      cursor.execute("select now()")
-    finally:
-      conn.close()
+        try:
+            cursor = conn.cursor()
+            cursor.execute("select now()")
+        finally:
+            conn.close()
 
-  def checkSchema(self):
-    pass
+    def check_schema(self):
+        pass
 
-  def dropSchema(self):
-    conn = self.getConnection()
+    def drop_schema(self):
+        conn = self.get_connection()
 
-    try:
-      cursor = conn.cursor()
+        try:
+            cursor = conn.cursor()
 
-      try:
-        cursor.execute("drop schema public cascade")
-      except ProgrammingError:
-        log.warn("The schema is already dropped")
+            try:
+                cursor.execute("drop schema public cascade")
+            except ProgrammingError:
+                log.warn("The schema is already dropped")
 
-      conn.commit()
-    finally:
-      conn.close()
+            conn.commit()
+        finally:
+            conn.close()
 
-  def __splitSQLStatements(self, text):
-    result = list()
-    unmatchedQuote = False
-    tmpStmt = ""
+    def __splitSQLStatements(self, text):
+        result = list()
+        unmatchedQuote = False
+        tmpStmt = ""
 
-    for stmt in text.split(";"):
-      stmt = stmt.rstrip()
-      quotePos = stmt.find("'")
-      while quotePos > 0:
-        quotePos += 1
-        if quotePos < len(stmt):
-          if stmt[quotePos] != "'":
-            unmatchedQuote = not unmatchedQuote
-          else:
-            # ignore 2 single quotes
-            quotePos += 1
-        quotePos = stmt.find("'", quotePos)
+        for stmt in text.split(";"):
+            stmt = stmt.rstrip()
+            quotePos = stmt.find("'")
+            while quotePos > 0:
+                quotePos += 1
+                if quotePos < len(stmt):
+                    if stmt[quotePos] != "'":
+                        unmatchedQuote = not unmatchedQuote
+                    else:
+                        # ignore 2 single quotes
+                        quotePos += 1
+                quotePos = stmt.find("'", quotePos)
 
-      if len(stmt.lstrip()) > 0:
-          tmpStmt += stmt + ";"
-          if not unmatchedQuote:
-            # single quote has been matched/closed, generate statement
-            result.append(tmpStmt.lstrip())
-            tmpStmt = ""
+            if len(stmt.lstrip()) > 0:
+                    tmpStmt += stmt + ";"
+                    if not unmatchedQuote:
+                        # single quote has been matched/closed, generate statement
+                        result.append(tmpStmt.lstrip())
+                        tmpStmt = ""
 
-    if unmatchedQuote:
-        result.append(tmpStmt.lstrip())
-    return result
+        if unmatchedQuote:
+                result.append(tmpStmt.lstrip())
+        return result
 
-  def loadSchema(self):
-    paths = list()
+    def load_schema(self):
+        paths = list()
 
-    paths.append(os.path.join(self.app.config.home, "sql", "schema.sql"))
-    paths.append(os.path.join(self.app.config.home, "sql", "indexes.sql"))
-    paths.append(os.path.join(self.app.config.home, "sql", "triggers.sql"))
+        paths.append(os.path.join(self.app.config.home, "sql", "schema.sql"))
+        paths.append(os.path.join(self.app.config.home, "sql", "indexes.sql"))
+        paths.append(os.path.join(self.app.config.home, "sql", "triggers.sql"))
 
-    scripts = list()
+        scripts = list()
 
-    for path in paths:
-      file = open(path, "r")
+        for path in paths:
+            file = open(path, "r")
 
-      try:
-        scripts.append((path, file.read()))
-      finally:
-        file.close()
+            try:
+                scripts.append((path, file.read()))
+            finally:
+                file.close()
 
-    conn = self.getConnection()
+        conn = self.get_connection()
 
-    try:
-      cursor = conn.cursor()
+        try:
+            cursor = conn.cursor()
 
-      try:
-        cursor.execute("create schema public");
-      except:
-        conn.rollback()
-        pass
+            try:
+                cursor.execute("create schema public");
+            except:
+                conn.rollback()
+                pass
 
-      for path, text in scripts:
-        stmts = self.__splitSQLStatements(text)
-        count = 0
+            for path, text in scripts:
+                stmts = self.__splitSQLStatements(text)
+                count = 0
 
-        for stmt in stmts:
-          stmt = stmt.strip()
+                for stmt in stmts:
+                    stmt = stmt.strip()
 
-          if stmt:
-            try:
-              cursor.execute(stmt)
-            except Exception, e:
-              print "Failed executing statement:"
-              print stmt
+                    if stmt:
+                        try:
+                            cursor.execute(stmt)
+                        except Exception, e:
+                            print "Failed executing statement:"
+                            print stmt
 
-              raise e
+                            raise e
 
-            count += 1
+                        count += 1
 
-        print "Executed %i statements from file '%s'" % (count, path)
+                print "Executed %i statements from file '%s'" % (count, path)
 
-      conn.commit()
+            conn.commit()
 
-      info = MintInfo(version="0.1")
-      info.sync()
+            info = MintInfo(version="0.1")
+            info.sync()
 
-      # Standard roles
+            # Standard roles
 
-      user = Role(name="user")
-      user.sync()
+            user = Role(name="user")
+            user.sync()
 
-      admin = Role(name="admin")
-      admin.sync()
-    finally:
-      conn.close()
+            admin = Role(name="admin")
+            admin.sync()
+        finally:
+            conn.close()
 
-  def checkSchema(self):
-    conn = self.getConnection()
+    def check_schema(self):
+        conn = self.get_connection()
 
-    try:
-      cursor = conn.cursor()
+        try:
+            cursor = conn.cursor()
 
-      try:
-        cursor.execute("select version from mint_info");
-      except Exception, e:
-        print "No schema present"
-        return
+            try:
+                cursor.execute("select version from mint_info");
+            except Exception, e:
+                print "No schema present"
+                return
 
-      for rec in cursor:
-        print "OK (version %s)" % rec[0]
-        return;
+            for rec in cursor:
+                print "OK (version %s)" % rec[0]
+                return;
 
-      print "No schema present"
-    finally:
-      conn.close()
+            print "No schema present"
+        finally:
+            conn.close()

Modified: mgmt/trunk/mint/python/mint/expire.py
===================================================================
--- mgmt/trunk/mint/python/mint/expire.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/expire.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -8,75 +8,79 @@
 log = logging.getLogger("mint.expire")
 
 class ExpireThread(MintDaemonThread):
-  def __init__(self, app):
-    super(ExpireThread, self).__init__(app)
+    def __init__(self, app):
+        super(ExpireThread, self).__init__(app)
 
-    self.keepCurrStats = False
+        self.keep_curr_stats = False
 
-    self.ops = []
-    self.attrs = dict()
+        self.ops = []
+        self.attrs = dict()
 
-  def init(self):
-    frequency = self.app.expireFrequency
-    threshold = self.app.expireThreshold
+    def init(self):
+        frequency = self.app.expire_frequency
+        threshold = self.app.expire_threshold
 
-    for cls in mint.schema.statsClasses:
-      self.ops.append(SqlExpire(eval(cls), self.keepCurrStats))
-    for cls in mint.schema.entityClasses:
-      self.ops.append(SqlExpire(eval(cls), self.keepCurrStats))
+        for cls in mint.schema.statsClasses:
+            self.ops.append(SqlExpire(eval(cls), self.keep_curr_stats))
+        for cls in mint.schema.entityClasses:
+            self.ops.append(SqlExpire(eval(cls), self.keep_curr_stats))
 
-    self.attrs["threshold"] = threshold
+        self.attrs["threshold"] = threshold
 
-    frequency_out, frequency_unit = self.__convertTimeUnits(frequency)
-    threshold_out, threshold_unit = self.__convertTimeUnits(threshold)
-    log.debug("Expiring database records older than %d %s, every %d %s" % \
-                (threshold_out, threshold_unit, frequency_out, frequency_unit))
+        frequency_out, frequency_unit = self.__convertTimeUnits(frequency)
+        threshold_out, threshold_unit = self.__convertTimeUnits(threshold)
 
-  def run(self):
-    frequency = self.app.expireFrequency
+        args = (threshold_out, threshold_unit, frequency_out, frequency_unit)
 
-    while True:
-      if self.stopRequested:
-        break
+        log.debug("Expiring database records older than %d %s, every %d %s" \
+                    % args)
+               
 
-      up = ExpireUpdate()
-      self.app.updateThread.enqueue(up)
+    def run(self):
+        frequency = self.app.expire_frequency
 
-      sleep(frequency)
+        while True:
+            if self.stop_requested:
+                break
 
-  def __convertTimeUnits(self, t):
-    if t / (24*3600) >= 1:
-      t_out = t / (24*3600)
-      t_unit = "days"
-    elif t / 3600 >= 1:
-      t_out = t / 3600
-      t_unit = "hours"
-    elif t / 60 >= 1:
-      t_out = t / 60
-      t_unit = "minutes"
-    else:
-      t_out = t
-      t_unit = "seconds"
-    return (t_out, t_unit)
+            up = ExpireUpdate()
+            self.app.update_thread.enqueue(up)
 
+            sleep(frequency)
+
+    def __convertTimeUnits(self, t):
+        if t / (24 * 3600) >= 1:
+            t_out = t / (24 * 3600)
+            t_unit = "days"
+        elif t / 3600 >= 1:
+            t_out = t / 3600
+            t_unit = "hours"
+        elif t / 60 >= 1:
+            t_out = t / 60
+            t_unit = "minutes"
+        else:
+            t_out = t
+            t_unit = "seconds"
+        return (t_out, t_unit)
+
 class ExpireUpdate(Update):
-  def do_process(self, conn, stats):
-    attrs = self.thread.app.expireThread.attrs
+    def do_process(self, conn, stats):
+        attrs = self.thread.app.expire_thread.attrs
 
-    cursor = conn.cursor()
-    total = 0
+        cursor = conn.cursor()
+        total = 0
 
-    for op in self.thread.app.expireThread.ops:
-      log.debug("Running expire op %s", op)
+        for op in self.thread.app.expire_thread.ops:
+            log.debug("Running expire op %s", op)
 
-      count = op.execute(cursor, attrs)
+            count = op.execute(cursor, attrs)
 
-      conn.commit()
+            conn.commit()
 
-      log.debug("%i records expired", count)
+            log.debug("%i records expired", count)
 
-      total += count
+            total += count
 
-    log.debug("%i total records expired", total)
+        log.debug("%i total records expired", total)
 
-    stats.expired += 1
+        stats.expired += 1

Modified: mgmt/trunk/mint/python/mint/main.py
===================================================================
--- mgmt/trunk/mint/python/mint/main.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/main.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -15,111 +15,111 @@
 log = logging.getLogger("mint.main")
 
 class Mint(Lifecycle):
-  def __init__(self, config):
-    self.log = log
+    def __init__(self, config):
+        self.log = log
 
-    self.config = config
-    self.database = MintDatabase(self)
-    self.model = MintModel(self)
+        self.config = config
+        self.database = MintDatabase(self)
+        self.model = MintModel(self)
 
-    self.updateEnabled = True
-    self.updateThread = UpdateThread(self)
+        self.update_enabled = True
+        self.update_thread = UpdateThread(self)
 
-    self.expireEnabled = True
-    self.expireFrequency = self.config.expire_frequency
-    self.expireThreshold = self.config.expire_threshold
-    self.expireThread = ExpireThread(self)
+        self.expire_enabled = True
+        self.expire_frequency = self.config.expire_frequency
+        self.expire_threshold = self.config.expire_threshold
+        self.expire_thread = ExpireThread(self)
 
-    self.vacuumEnabled = True
-    self.vacuumThread = VacuumThread(self)
+        self.vacuum_enabled = True
+        self.vacuum_thread = VacuumThread(self)
 
-  def check(self):
-    self.database.check()
-    self.model.check()
+    def check(self):
+        self.database.check()
+        self.model.check()
 
-  def do_init(self):
-    self.database.init()
-    self.model.init()
+    def do_init(self):
+        self.database.init()
+        self.model.init()
 
-    def state(cond):
-      return cond and "enabled" or "disabled"
+        def state(cond):
+            return cond and "enabled" or "disabled"
 
-    log.info("Updates are %s", state(self.updateEnabled))
-    log.info("Expiration is %s", state(self.expireEnabled))
+        log.info("Updates are %s", state(self.update_enabled))
+        log.info("Expiration is %s", state(self.expire_enabled))
 
-    self.updateThread.init()
-    self.expireThread.init()
-    self.vacuumThread.init()
+        self.update_thread.init()
+        self.expire_thread.init()
+        self.vacuum_thread.init()
 
-  def do_start(self):
-    self.model.start()
+    def do_start(self):
+        self.model.start()
 
-    if self.updateEnabled:
-      self.updateThread.start()
+        if self.update_enabled:
+            self.update_thread.start()
 
-    if self.expireEnabled:
-      self.expireThread.start()
+        if self.expire_enabled:
+            self.expire_thread.start()
 
-    if self.vacuumEnabled:
-      self.vacuumThread.start()
+        if self.vacuum_enabled:
+            self.vacuum_thread.start()
 
-  def do_stop(self):
-    self.model.stop()
+    def do_stop(self):
+        self.model.stop()
 
-    if self.updateEnabled:
-      self.updateThread.stop()
+        if self.update_enabled:
+            self.update_thread.stop()
 
-    if self.expireEnabled:
-      self.expireThread.stop()
+        if self.expire_enabled:
+            self.expire_thread.stop()
 
-    if self.vacuumEnabled:
-      self.vacuumThread.stop()
+        if self.vacuum_enabled:
+            self.vacuum_thread.stop()
 
 class MintConfig(Config):
-  def __init__(self):
-    super(MintConfig, self).__init__()
+    def __init__(self):
+        super(MintConfig, self).__init__()
 
-    hdef = os.path.normpath("/var/lib/cumin")
-    hdef = os.environ.get("CUMIN_HOME", hdef)
-    self.home = os.environ.get("MINT_HOME", hdef)
+        hdef = os.path.normpath("/var/lib/cumin")
+        hdef = os.environ.get("CUMIN_HOME", hdef)
+        self.home = os.environ.get("MINT_HOME", hdef)
 
-    if not os.path.isdir(self.home):
-      raise Exception("Home path '%s' is not a directory")
+        if not os.path.isdir(self.home):
+            raise Exception("Home path '%s' is not a directory")
 
-    param = ConfigParameter(self, "data", str)
-    param.default = "postgresql://mint@localhost/mint"
+        param = ConfigParameter(self, "data", str)
+        param.default = "postgresql://mint@localhost/mint"
 
-    param = ConfigParameter(self, "qmf", str)
-    param.default = "amqp://localhost"
+        param = ConfigParameter(self, "qmf", str)
+        param.default = "amqp://localhost"
 
-    param = ConfigParameter(self, "log-file", str)
-    param.default = os.path.join(self.home, "log", "mint.log")
+        param = ConfigParameter(self, "log-file", str)
+        param.default = os.path.join(self.home, "log", "mint.log")
 
-    param = ConfigParameter(self, "log-level", str)
-    param.default = "warn"
+        param = ConfigParameter(self, "log-level", str)
+        param.default = "warn"
 
-    param = ConfigParameter(self, "debug", bool)
-    param.default = False
+        param = ConfigParameter(self, "debug", bool)
+        param.default = False
 
-    param = ConfigParameter(self, "expire-frequency", int)
-    param.default = 600 # 10 minutes
+        param = ConfigParameter(self, "expire-frequency", int)
+        param.default = 600 # 10 minutes
 
-    param = ConfigParameter(self, "expire-threshold", int)
-    param.default = 24 * 3600 # 1 day
+        param = ConfigParameter(self, "expire-threshold", int)
+        param.default = 24 * 3600 # 1 day
 
-  def init(self):
-    super(MintConfig, self).init()
+    def init(self):
+        super(MintConfig, self).init()
 
-    self.load_file(os.path.join(self.home, "etc", "cumin.conf"))
-    self.load_file(os.path.join(self.home, "etc", "mint.conf"))
+        self.load_file(os.path.join(self.home, "etc", "cumin.conf"))
+        self.load_file(os.path.join(self.home, "etc", "mint.conf"))
 
-    self.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
-    self.load_file(os.path.join(os.path.expanduser("~"), ".mint.conf"))
+        self.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
+        self.load_file(os.path.join(os.path.expanduser("~"), ".mint.conf"))
 
-    enable_logging("mint", self.log_level, self.log_file)
+        enable_logging("mint", self.log_level, self.log_file)
 
 def get_addr_for_vhost(vhost):
-  broker = vhost.broker
-  host = broker.system.nodeName
-  port = broker.port
-  return (host, port)
+    broker = vhost.broker
+    host = broker.system.nodeName
+    port = broker.port
+    return (host, port)

Modified: mgmt/trunk/mint/python/mint/model.py
===================================================================
--- mgmt/trunk/mint/python/mint/model.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/model.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -15,233 +15,234 @@
 log = logging.getLogger("mint.model")
 
 class MintModel(Lifecycle):
-  def __init__(self, app):
-    self.log = log
+    def __init__(self, app):
+        self.log = log
 
-    assert mint.schema.model is None
-    mint.schema.model = self
+        assert mint.schema.model is None
+        mint.schema.model = self
 
-    self.app = app
+        self.app = app
 
-    self.qmf_session = None
-    self.qmf_brokers = list()
+        self.qmf_session = None
+        self.qmf_brokers = list()
 
-    # qmfAgentId => MintAgent
-    self.agents = dict()
+        # qmfAgentId => MintAgent
+        self.agents = dict()
 
-    # int seq => callable
-    self.outstanding_method_calls = dict()
+        # int seq => callable
+        self.outstanding_method_calls = dict()
 
-    self.lock = RLock()
+        self.lock = RLock()
 
-  def check(self):
-    pass
+    def check(self):
+        pass
 
-  def do_init(self):
-    assert self.qmf_session is None
+    def do_init(self):
+        assert self.qmf_session is None
 
-    self.qmf_session = Session(MintConsole(self),
-                               manageConnections=True,
-                               rcvObjects=self.app.updateEnabled)
+        self.qmf_session = Session(MintConsole(self),
+                                   manageConnections=True,
+                                   rcvObjects=self.app.update_enabled)
 
-  def do_start(self):
-    # Clean up any transient objects that a previous instance may have
-    # left behind in the DB; it's basically an unconstrained agent
-    # disconnect update, for any agent
+    def do_start(self):
+        # Clean up any transient objects that a previous instance may
+        # have left behind in the DB; it's basically an unconstrained
+        # agent disconnect update, for any agent
 
-    up = AgentDisconnectUpdate(None)
-    self.app.updateThread.enqueue(up)
+        up = AgentDisconnectUpdate(None)
+        self.app.update_thread.enqueue(up)
 
-    uris = [x.strip() for x in self.app.config.qmf.split(",")]
+        uris = [x.strip() for x in self.app.config.qmf.split(",")]
 
-    for uri in uris:
-      self.add_broker(uri)
+        for uri in uris:
+            self.add_broker(uri)
 
-  def do_stop(self):
-    for qbroker in self.qmf_brokers:
-      self.qmf_session.delBroker(qbroker)
+    def do_stop(self):
+        for qbroker in self.qmf_brokers:
+            self.qmf_session.delBroker(qbroker)
 
-  def add_broker(self, url):
-    log.info("Adding qmf broker at %s", url)
+    def add_broker(self, url):
+        log.info("Adding qmf broker at %s", url)
 
-    self.lock.acquire()
-    try:
-      qbroker = self.qmf_session.addBroker(url)
-      self.qmf_brokers.append(qbroker)
-    finally:
-      self.lock.release()
+        self.lock.acquire()
+        try:
+            qbroker = self.qmf_session.addBroker(url)
+            self.qmf_brokers.append(qbroker)
+        finally:
+            self.lock.release()
 
 class MintAgent(object):
-  def __init__(self, model, agent):
-    self.model = model
-    self.agent = agent
+    def __init__(self, model, agent):
+        self.model = model
+        self.agent = agent
 
-    self.id = str(QmfAgentId.fromAgent(agent))
+        self.id = str(QmfAgentId.fromAgent(agent))
 
-    self.last_heartbeat = None
+        self.last_heartbeat = None
 
-    # qmfObjectId => int database id
-    self.database_ids = MintCache()
+        # qmfObjectId => int database id
+        self.database_ids = MintCache()
 
-    # qmfObjectId => list of ModelUpdate objects
-    self.deferred_updates = defaultdict(list)
+        # qmfObjectId => list of ModelUpdate objects
+        self.deferred_updates = defaultdict(list)
 
-    self.model.lock.acquire()
-    try:
-      assert self.id not in self.model.agents
-      self.model.agents[self.id] = self
-    finally:
-      self.model.lock.release()
+        self.model.lock.acquire()
+        try:
+            assert self.id not in self.model.agents
+            self.model.agents[self.id] = self
+        finally:
+            self.model.lock.release()
 
-  def callMethod(self, mintObject, methodName, callback, args):
-    classKey = ClassKey(mintObject.qmfClassKey)
-    objectId = QmfObjectId.fromString(mintObject.qmfObjectId).toObjectId()
+    def call_method(self, object, name, callback, args):
+        classKey = ClassKey(object.qmfClassKey)
+        objectId = QmfObjectId.fromString(object.qmfObjectId).toObjectId()
 
-    self.model.lock.acquire()
-    try:
-      broker = self.agent.getBroker()
+        self.model.lock.acquire()
+        try:
+            broker = self.agent.getBroker()
 
-      seq = self.model.qmf_session._sendMethodRequest \
-          (broker, classKey, objectId, methodName, args)
+            seq = self.model.qmf_session._sendMethodRequest \
+                    (broker, classKey, objectId, name, args)
 
-      if seq is not None:
-        self.model.outstanding_method_calls[seq] = callback
+            if seq is not None:
+                self.model.outstanding_method_calls[seq] = callback
 
-      return seq
-    finally:
-      self.model.lock.release()
+            return seq
+        finally:
+            self.model.lock.release()
 
-  def delete(self):
-    self.model.lock.acquire()
-    try:
-      del self.model.agents[self.id]
-    finally:
-      self.model.lock.release()
- 
-    self.model = None
+    def delete(self):
+        self.model.lock.acquire()
+        try:
+            del self.model.agents[self.id]
+        finally:
+            self.model.lock.release()
 
-  def __repr__(self):
-    return "%s(%s)" % (self.__class__.__name__, self.id)
+        self.model = None
 
+    def __repr__(self):
+        return "%s(%s)" % (self.__class__.__name__, self.id)
+
 class MintConsole(Console):
-  def __init__(self, model):
-    self.model = model
+    def __init__(self, model):
+        self.model = model
 
-    self.deferred_object_prop_calls = defaultdict(list)
-    self.deferred_object_stat_calls = defaultdict(list)
+        self.deferred_object_prop_calls = defaultdict(list)
+        self.deferred_object_stat_calls = defaultdict(list)
 
-  def brokerConnected(self, qbroker):
-    log.info("Broker at %s:%i is connected", qbroker.host, qbroker.port)
+    def brokerConnected(self, qbroker):
+        log.info("Broker at %s:%i is connected", qbroker.host, qbroker.port)
 
-  def brokerInfo(self, qbroker):
-    # Now we have a brokerId to use to generate fully qualified agent
-    # IDs
+    def brokerInfo(self, qbroker):
+        # Now we have a brokerId to use to generate fully qualified agent
+        # IDs
 
-    for qagent in qbroker.getAgents():
-      MintAgent(self.model, qagent)
+        for qagent in qbroker.getAgents():
+            MintAgent(self.model, qagent)
 
-  def brokerDisconnected(self, qbroker):
-    log.info("Broker at %s:%i is disconnected", qbroker.host, qbroker.port)
+    def brokerDisconnected(self, qbroker):
+        log.info("Broker at %s:%i is disconnected", qbroker.host, qbroker.port)
 
-  def newAgent(self, qagent):
-    log.info("Creating %s", qagent)
+    def newAgent(self, qagent):
+        log.info("Creating %s", qagent)
 
-    # Some agents come down without a brokerId, meaning we can't
-    # generate a fully qualified agent ID for them.  Those we handle
-    # in brokerInfo.
+        # Some agents come down without a brokerId, meaning we can't
+        # generate a fully qualified agent ID for them.    Those we handle
+        # in brokerInfo.
 
-    if qagent.getBroker().brokerId:
-      agent = MintAgent(self.model, qagent)
+        if qagent.getBroker().brokerId:
+            agent = MintAgent(self.model, qagent)
 
-      # XXX This business is to handle an agent-vs-agent-data ordering
-      # problem
+            # XXX This business is to handle an agent-vs-agent-data ordering
+            # problem
 
-      objectPropCalls = self.deferred_object_prop_calls[agent.id]
+            objectPropCalls = self.deferred_object_prop_calls[agent.id]
 
-      for broker, object in objectPropCalls:
-        self.objectProps(broker, object)
+            for broker, object in objectPropCalls:
+                self.objectProps(broker, object)
 
-      objectStatCalls = self.deferred_object_stat_calls[agent.id]
+            objectStatCalls = self.deferred_object_stat_calls[agent.id]
 
-      for broker, object in objectStatCalls:
-        self.objectStats(broker, object)
+            for broker, object in objectStatCalls:
+                self.objectStats(broker, object)
 
-  def delAgent(self, qagent):
-    log.info("Deleting %s", qagent)
+    def delAgent(self, qagent):
+        log.info("Deleting %s", qagent)
 
-    id = str(QmfAgent.fromAgent(qagent))
+        id = str(QmfAgentId.fromAgent(qagent))
 
-    agent = self.model.agents[id]
-    agent.delete()
- 
-    up = AgentDisconnectUpdate(agent)
-    self.model.app.updateThread.enqueue(up)
+        agent = self.model.agents[id]
+        agent.delete()
 
-  def heartbeat(self, qagent, timestamp):
-    timestamp = timestamp / 1000000000
+        up = AgentDisconnectUpdate(agent)
+        self.model.app.update_thread.enqueue(up)
 
-    id = str(QmfAgentId.fromAgent(qagent))
+    def heartbeat(self, qagent, timestamp):
+        timestamp = timestamp / 1000000000
 
-    agent = self.model.agents[id]
-    agent.last_heartbeat = datetime.fromtimestamp(timestamp)
+        id = str(QmfAgentId.fromAgent(qagent))
 
-  def newPackage(self, name):
-    log.info("New package %s", name)
+        agent = self.model.agents[id]
+        agent.last_heartbeat = datetime.fromtimestamp(timestamp)
 
-  def newClass(self, kind, classKey):
-    log.info("New class %s", classKey)
+    def newPackage(self, name):
+        log.info("New package %s", name)
 
-  def objectProps(self, broker, object):
-    if not self.model.app.updateThread.isAlive():
-      return
+    def newClass(self, kind, classKey):
+        log.info("New class %s", classKey)
 
-    self.model.lock.acquire()
-    try:
-      id = str(QmfAgentId.fromObject(object))
+    def objectProps(self, broker, object):
+        if not self.model.app.update_thread.isAlive():
+            return
 
-      try:
-        agent = self.model.agents[id]
-      except KeyError:
-        self.deferred_object_prop_calls[id].append((broker, object))
-        return
-    finally:
-      self.model.lock.release()
+        self.model.lock.acquire()
+        try:
+            id = str(QmfAgentId.fromObject(object))
 
-    up = PropertyUpdate(agent, object)
-    self.model.app.updateThread.enqueue(up)
+            try:
+                agent = self.model.agents[id]
+            except KeyError:
+                self.deferred_object_prop_calls[id].append((broker, object))
+                return
+        finally:
+            self.model.lock.release()
 
-  def objectStats(self, broker, object):
-    """ Invoked when an object is updated. """
+        up = PropertyUpdate(agent, object)
+        self.model.app.update_thread.enqueue(up)
 
-    if not self.model.app.updateThread.isAlive():
-      return
+    def objectStats(self, broker, object):
+        """ Invoked when an object is updated. """
 
-    self.model.lock.acquire()
-    try:
-      id = str(QmfAgentId.fromObject(object))
+        if not self.model.app.update_thread.isAlive():
+            return
 
-      try:
-        agent = self.model.agents[id]
-      except KeyError:
-        self.deferred_object_stat_calls[id].append((broker, object))
-        return
-    finally:
-      self.model.lock.release()
+        self.model.lock.acquire()
+        try:
+            id = str(QmfAgentId.fromObject(object))
 
-    up = StatisticUpdate(agent, object)
-    self.model.app.updateThread.enqueue(up)
+            try:
+                agent = self.model.agents[id]
+            except KeyError:
+                self.deferred_object_stat_calls[id].append((broker, object))
+                return
+        finally:
+            self.model.lock.release()
 
-  def event(self, broker, event):
-    """ Invoked when an event is raised. """
-    pass
+        up = StatisticUpdate(agent, object)
+        self.model.app.update_thread.enqueue(up)
 
-  def methodResponse(self, broker, seq, response):
-    log.info("Method response for request %i received from %s", seq, broker)
-    log.debug("Response: %s", response)
+    def event(self, broker, event):
+        """ Invoked when an event is raised. """
+        pass
 
-    self.model.lock.acquire()
-    try:
-      callback = self.model.outstanding_method_calls.pop(seq)
-      callback(response.text, response.outArgs)
-    finally:
-      self.model.lock.release()
+    def methodResponse(self, broker, seq, response):
+        log.info("Method response for request %i received from %s",
+                 seq, broker)
+        log.debug("Response: %s", response)
+
+        self.model.lock.acquire()
+        try:
+            callback = self.model.outstanding_method_calls.pop(seq)
+            callback(response.text, response.outArgs)
+        finally:
+            self.model.lock.release()

Modified: mgmt/trunk/mint/python/mint/schema.py
===================================================================
--- mgmt/trunk/mint/python/mint/schema.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/schema.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -165,7 +165,7 @@
     if Id is not None:
       args.append(Id)
 
-    agent.callMethod(self, "Submit", callback, args)
+    agent.call_method(self, "Submit", callback, args)
 
   def GetAd(self, callback, Id, JobAd):
     try:
@@ -180,7 +180,7 @@
     if JobAd is not None:
       args.append(JobAd)
 
-    agent.callMethod(self, "GetAd", callback, args)
+    agent.call_method(self, "GetAd", callback, args)
 
   def SetAttribute(self, callback, Id, Name, Value):
     try:
@@ -197,7 +197,7 @@
     if Value is not None:
       args.append(Value)
 
-    agent.callMethod(self, "SetAttribute", callback, args)
+    agent.call_method(self, "SetAttribute", callback, args)
 
   def Hold(self, callback, Id, Reason):
     try:
@@ -212,7 +212,7 @@
     if Reason is not None:
       args.append(Reason)
 
-    agent.callMethod(self, "Hold", callback, args)
+    agent.call_method(self, "Hold", callback, args)
 
   def Release(self, callback, Id, Reason):
     try:
@@ -227,7 +227,7 @@
     if Reason is not None:
       args.append(Reason)
 
-    agent.callMethod(self, "Release", callback, args)
+    agent.call_method(self, "Release", callback, args)
 
   def Remove(self, callback, Id, Reason):
     try:
@@ -242,7 +242,7 @@
     if Reason is not None:
       args.append(Reason)
 
-    agent.callMethod(self, "Remove", callback, args)
+    agent.call_method(self, "Remove", callback, args)
 
   def Fetch(self, callback, Id, File, Start, End, Data):
     try:
@@ -263,7 +263,7 @@
     if Data is not None:
       args.append(Data)
 
-    agent.callMethod(self, "Fetch", callback, args)
+    agent.call_method(self, "Fetch", callback, args)
 
   def GetStates(self, callback, Submission, State, Count):
     try:
@@ -280,7 +280,7 @@
     if Count is not None:
       args.append(Count)
 
-    agent.callMethod(self, "GetStates", callback, args)
+    agent.call_method(self, "GetStates", callback, args)
 
   def GetJobs(self, callback, Submission, Jobs):
     try:
@@ -295,7 +295,7 @@
     if Jobs is not None:
       args.append(Jobs)
 
-    agent.callMethod(self, "GetJobs", callback, args)
+    agent.call_method(self, "GetJobs", callback, args)
 
   def echo(self, callback, sequence, body):
     try:
@@ -310,7 +310,7 @@
     if body is not None:
       args.append(body)
 
-    agent.callMethod(self, "echo", callback, args)
+    agent.call_method(self, "echo", callback, args)
 
 class SchedulerStats(SQLObject):
   class sqlmeta:
@@ -405,7 +405,7 @@
     if Limits is not None:
       args.append(Limits)
 
-    agent.callMethod(self, "GetLimits", callback, args)
+    agent.call_method(self, "GetLimits", callback, args)
 
   def SetLimit(self, callback, Name, Max):
     try:
@@ -420,7 +420,7 @@
     if Max is not None:
       args.append(Max)
 
-    agent.callMethod(self, "SetLimit", callback, args)
+    agent.call_method(self, "SetLimit", callback, args)
 
   def GetStats(self, callback, Name, Ad):
     try:
@@ -435,7 +435,7 @@
     if Ad is not None:
       args.append(Ad)
 
-    agent.callMethod(self, "GetStats", callback, args)
+    agent.call_method(self, "GetStats", callback, args)
 
   def SetPriority(self, callback, Name, Priority):
     try:
@@ -450,7 +450,7 @@
     if Priority is not None:
       args.append(Priority)
 
-    agent.callMethod(self, "SetPriority", callback, args)
+    agent.call_method(self, "SetPriority", callback, args)
 
   def SetPriorityFactor(self, callback, Name, PriorityFactor):
     try:
@@ -465,7 +465,7 @@
     if PriorityFactor is not None:
       args.append(PriorityFactor)
 
-    agent.callMethod(self, "SetPriorityFactor", callback, args)
+    agent.call_method(self, "SetPriorityFactor", callback, args)
 
   def SetUsage(self, callback, Name, Usage):
     try:
@@ -480,7 +480,7 @@
     if Usage is not None:
       args.append(Usage)
 
-    agent.callMethod(self, "SetUsage", callback, args)
+    agent.call_method(self, "SetUsage", callback, args)
 
   def GetRawConfig(self, callback, Name, Value):
     try:
@@ -495,7 +495,7 @@
     if Value is not None:
       args.append(Value)
 
-    agent.callMethod(self, "GetRawConfig", callback, args)
+    agent.call_method(self, "GetRawConfig", callback, args)
 
   def SetRawConfig(self, callback, Name, Value):
     try:
@@ -510,7 +510,7 @@
     if Value is not None:
       args.append(Value)
 
-    agent.callMethod(self, "SetRawConfig", callback, args)
+    agent.call_method(self, "SetRawConfig", callback, args)
 
   def Reconfig(self, callback):
     try:
@@ -521,7 +521,7 @@
     args = list()
 
 
-    agent.callMethod(self, "Reconfig", callback, args)
+    agent.call_method(self, "Reconfig", callback, args)
 
 class NegotiatorStats(SQLObject):
   class sqlmeta:
@@ -616,7 +616,7 @@
     if Subsystem is not None:
       args.append(Subsystem)
 
-    agent.callMethod(self, "Start", callback, args)
+    agent.call_method(self, "Start", callback, args)
 
   def Stop(self, callback, Subsystem):
     try:
@@ -629,7 +629,7 @@
     if Subsystem is not None:
       args.append(Subsystem)
 
-    agent.callMethod(self, "Stop", callback, args)
+    agent.call_method(self, "Stop", callback, args)
 
 class MasterStats(SQLObject):
   class sqlmeta:
@@ -753,7 +753,7 @@
     args = list()
 
 
-    agent.callMethod(self, "reloadACLFile", callback, args)
+    agent.call_method(self, "reloadACLFile", callback, args)
 
 class AclStats(SQLObject):
   class sqlmeta:
@@ -802,7 +802,7 @@
     if brokerId is not None:
       args.append(brokerId)
 
-    agent.callMethod(self, "stopClusterNode", callback, args)
+    agent.call_method(self, "stopClusterNode", callback, args)
 
   def stopFullCluster(self, callback):
     try:
@@ -813,7 +813,7 @@
     args = list()
 
 
-    agent.callMethod(self, "stopFullCluster", callback, args)
+    agent.call_method(self, "stopFullCluster", callback, args)
 
 class ClusterStats(SQLObject):
   class sqlmeta:
@@ -912,7 +912,7 @@
     if by is not None:
       args.append(by)
 
-    agent.callMethod(self, "expand", callback, args)
+    agent.call_method(self, "expand", callback, args)
 
 class JournalStats(SQLObject):
   class sqlmeta:
@@ -1024,7 +1024,7 @@
     if body is not None:
       args.append(body)
 
-    agent.callMethod(self, "echo", callback, args)
+    agent.call_method(self, "echo", callback, args)
 
   def connect(self, callback, host, port, durable, authMechanism, username, password, transport):
     """Establish a connection to another broker"""
@@ -1050,7 +1050,7 @@
     if transport is not None:
       args.append(transport)
 
-    agent.callMethod(self, "connect", callback, args)
+    agent.call_method(self, "connect", callback, args)
 
   def queueMoveMessages(self, callback, srcQueue, destQueue, qty):
     """Move messages from one queue to another"""
@@ -1068,7 +1068,7 @@
     if qty is not None:
       args.append(qty)
 
-    agent.callMethod(self, "queueMoveMessages", callback, args)
+    agent.call_method(self, "queueMoveMessages", callback, args)
 
 class BrokerStats(SQLObject):
   class sqlmeta:
@@ -1177,7 +1177,7 @@
     if request is not None:
       args.append(request)
 
-    agent.callMethod(self, "purge", callback, args)
+    agent.call_method(self, "purge", callback, args)
 
 class QueueStats(SQLObject):
   class sqlmeta:
@@ -1362,7 +1362,7 @@
     args = list()
 
 
-    agent.callMethod(self, "close", callback, args)
+    agent.call_method(self, "close", callback, args)
 
 class ClientConnectionStats(SQLObject):
   class sqlmeta:
@@ -1409,7 +1409,7 @@
     args = list()
 
 
-    agent.callMethod(self, "close", callback, args)
+    agent.call_method(self, "close", callback, args)
 
   def bridge(self, callback, durable, src, dest, key, tag, excludes, srcIsQueue, srcIsLocal, dynamic, sync):
     """Bridge messages over the link"""
@@ -1441,7 +1441,7 @@
     if sync is not None:
       args.append(sync)
 
-    agent.callMethod(self, "bridge", callback, args)
+    agent.call_method(self, "bridge", callback, args)
 
 class LinkStats(SQLObject):
   class sqlmeta:
@@ -1492,7 +1492,7 @@
     args = list()
 
 
-    agent.callMethod(self, "close", callback, args)
+    agent.call_method(self, "close", callback, args)
 
 class BridgeStats(SQLObject):
   class sqlmeta:
@@ -1537,7 +1537,7 @@
     args = list()
 
 
-    agent.callMethod(self, "solicitAck", callback, args)
+    agent.call_method(self, "solicitAck", callback, args)
 
   def detach(self, callback):
     try:
@@ -1548,7 +1548,7 @@
     args = list()
 
 
-    agent.callMethod(self, "detach", callback, args)
+    agent.call_method(self, "detach", callback, args)
 
   def resetLifespan(self, callback):
     try:
@@ -1559,7 +1559,7 @@
     args = list()
 
 
-    agent.callMethod(self, "resetLifespan", callback, args)
+    agent.call_method(self, "resetLifespan", callback, args)
 
   def close(self, callback):
     try:
@@ -1570,7 +1570,7 @@
     args = list()
 
 
-    agent.callMethod(self, "close", callback, args)
+    agent.call_method(self, "close", callback, args)
 
 class SessionStats(SQLObject):
   class sqlmeta:

Modified: mgmt/trunk/mint/python/mint/schemalocal.py
===================================================================
--- mgmt/trunk/mint/python/mint/schemalocal.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/schemalocal.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -3,73 +3,74 @@
 from mint.util import *
 
 class Subject(SQLObject):
-  class sqlmeta:
-    lazyUpdate = True
+    class sqlmeta:
+        lazyUpdate = True
 
-  name = StringCol(unique=True, notNone=True)
-  password = StringCol()
-  lastChallenged = TimestampCol(default=None)
-  lastLoggedIn = TimestampCol(default=None)
-  lastLoggedOut = TimestampCol(default=None)
-  roles = SQLRelatedJoin("Role", intermediateTable="subject_role_mapping",
-                         createRelatedTable=False)
+    name = StringCol(unique=True, notNone=True)
+    password = StringCol()
+    lastChallenged = TimestampCol(default=None)
+    lastLoggedIn = TimestampCol(default=None)
+    lastLoggedOut = TimestampCol(default=None)
+    roles = SQLRelatedJoin("Role",
+                           intermediateTable="subject_role_mapping",
+                           createRelatedTable=False)
 
-  def getByName(cls, name):
-    try:
-      return Subject.selectBy(name=name)[0]
-    except IndexError:
-      pass
+    def getByName(cls, name):
+        try:
+            return Subject.selectBy(name=name)[0]
+        except IndexError:
+            pass
 
-  getByName = classmethod(getByName)
+    getByName = classmethod(getByName)
 
 class Role(SQLObject):
-  class sqlmeta:
-    lazyUpdate = True
+    class sqlmeta:
+        lazyUpdate = True
 
-  name = StringCol(unique=True, notNone=True)
-  subjects = SQLRelatedJoin("Subject",
-                            intermediateTable="subject_role_mapping",
-                            createRelatedTable=False)
+    name = StringCol(unique=True, notNone=True)
+    subjects = SQLRelatedJoin("Subject",
+                              intermediateTable="subject_role_mapping",
+                              createRelatedTable=False)
 
-  def getByName(cls, name):
-    try:
-      return Role.selectBy(name=name)[0]
-    except IndexError:
-      pass
+    def getByName(cls, name):
+        try:
+            return Role.selectBy(name=name)[0]
+        except IndexError:
+            pass
 
-  getByName = classmethod(getByName)
+    getByName = classmethod(getByName)
 
 class SubjectRoleMapping(SQLObject):
-  class sqlmeta:
-    lazyUpdate = True
+    class sqlmeta:
+        lazyUpdate = True
 
-  subject = ForeignKey("Subject", notNull=True, cascade=True)
-  role = ForeignKey("Role", notNull=True, cascade=True)
-  unique = DatabaseIndex(subject, role, unique=True)
+    subject = ForeignKey("Subject", notNull=True, cascade=True)
+    role = ForeignKey("Role", notNull=True, cascade=True)
+    unique = DatabaseIndex(subject, role, unique=True)
 
 class ObjectNotFound(Exception):
-  pass
+    pass
 
 class MintInfo(SQLObject):
-  class sqlmeta:
-    lazyUpdate = True
+    class sqlmeta:
+        lazyUpdate = True
 
-  version = StringCol(default="0.1", notNone=True)
+    version = StringCol(default="0.1", notNone=True)
 
 class BrokerGroup(SQLObject):
-  class sqlmeta:
-    lazyUpdate = True
+    class sqlmeta:
+        lazyUpdate = True
 
-  name = StringCol(unique=True, notNone=True)
-  brokers = SQLRelatedJoin("Broker",
-                           intermediateTable="broker_group_mapping",
-                           createRelatedTable=False)
+    name = StringCol(unique=True, notNone=True)
+    brokers = SQLRelatedJoin("Broker",
+                             intermediateTable="broker_group_mapping",
+                             createRelatedTable=False)
 
 class BrokerGroupMapping(SQLObject):
-  class sqlmeta:
-    lazyUpdate = True
+    class sqlmeta:
+        lazyUpdate = True
 
-  broker = ForeignKey("Broker", notNull=True, cascade=True)
-  brokerGroup = ForeignKey("BrokerGroup", notNull=True, cascade=True)
-  unique = DatabaseIndex(broker, brokerGroup, unique=True)
+    broker = ForeignKey("Broker", notNull=True, cascade=True)
+    brokerGroup = ForeignKey("BrokerGroup", notNull=True, cascade=True)
+    unique = DatabaseIndex(broker, brokerGroup, unique=True)
 

Modified: mgmt/trunk/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/trunk/mint/python/mint/schemaparser.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/schemaparser.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -194,7 +194,7 @@
     self.pythonOutput += "    except KeyError:\n"
     self.pythonOutput += "      raise Exception(\"Agent not found\")\n\n"
     self.pythonOutput += actualArgs + "\n"
-    self.pythonOutput += "    agent.callMethod(self, \"%s\", " % elem["@name"]
+    self.pythonOutput += "    agent.call_method(self, \"%s\", " % elem["@name"]
     self.pythonOutput += "callback, args)\n"
 
   def endClass(self):

Modified: mgmt/trunk/mint/python/mint/sql.py
===================================================================
--- mgmt/trunk/mint/python/mint/sql.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/sql.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -1,4 +1,5 @@
 import logging, mint
+
 from time import clock
 from sqlobject import MixedCaseUnderscoreStyle
 
@@ -7,243 +8,244 @@
 dbStyle = MixedCaseUnderscoreStyle()
 profile = None
 
-def transformTable(table):
-  try:
-    table = mint.schema.schemaReservedWordsMap[table]
-  except KeyError:
-    pass
+def transform_table(table):
+    try:
+        table = mint.schema.schemaReservedWordsMap[table]
+    except KeyError:
+        pass
 
-  table = table[0] + table[1:] # XXX why is this necessary?
-  table = dbStyle.pythonClassToDBTable(table)
+    table = table[0] + table[1:] # XXX why is this necessary?
+    table = dbStyle.pythonClassToDBTable(table)
 
-  return table
+    return table
 
-def transformColumn(column):
-  return dbStyle.pythonAttrToDBColumn(column)
+def transform_column(column):
+    return dbStyle.pythonAttrToDBColumn(column)
 
 class SqlOperation(object):
-  def __init__(self, name):
-    self.name = name
+    def __init__(self, name):
+        self.name = name
 
-    self.time = None
-    self.text = None
+        self.time = None
+        self.text = None
 
-    if profile:
-      profile.ops.append(self)
+        if profile:
+            profile.ops.append(self)
 
-  def key(self):
-    if hasattr(self, "cls"):
-      return "%s(%s)" % (self.name, getattr(self, "cls").__name__)
-    else:
-      return self.name
+    def key(self):
+        if hasattr(self, "cls"):
+            return "%s(%s)" % (self.name, getattr(self, "cls").__name__)
+        else:
+            return self.name
 
-  def __repr__(self):
-    return self.key()
+    def __repr__(self):
+        return self.key()
 
-  def generate(self):
-    pass
+    def generate(self):
+        pass
 
-  def execute(self, cursor, values=None):
-    self.text = self.generate()
+    def execute(self, cursor, values=None):
+        self.text = self.generate()
 
-    try:
-      if profile:
-        start = clock()
-        cursor.execute(self.text, values)
-        self.time = clock() - start
-      else:
-        cursor.execute(self.text, values)
-      return cursor.rowcount
-    except:
-      log.warn("Text: %s", self.text)
+        try:
+            if profile:
+                start = clock()
+                cursor.execute(self.text, values)
+                self.time = clock() - start
+            else:
+                cursor.execute(self.text, values)
+            return cursor.rowcount
+        except:
+            log.warn("Text: %s", self.text)
 
-      if values:
-        for item in values.items():
-          log.warn("  %-20s  %r", *item)
+            if values:
+                for item in values.items():
+                    log.warn("    %-20s    %r", *item)
 
-      raise
+            raise
 
 class SqlGetId(SqlOperation):
-  def __init__(self, cls):
-    super(SqlGetId, self).__init__("get_id")
+    def __init__(self, cls):
+        super(SqlGetId, self).__init__("get_id")
 
-    self.cls = cls
+        self.cls = cls
 
-  def generate(self):
-    table = self.cls.sqlmeta.table
+    def generate(self):
+        table = self.cls.sqlmeta.table
 
-    return """
-      select id
-      from %s
-      where qmf_agent_id = %%(qmfAgentId)s and qmf_object_id = %%(qmfObjectId)s
-    """ % table
+        return """
+            select id
+            from %s
+            where qmf_agent_id = %%(qmfAgentId)s and qmf_object_id = %%(qmfObjectId)s
+        """ % table
 
 class SqlSetStatsRefs(SqlOperation):
-  def __init__(self, cls):
-    super(SqlSetStatsRefs, self).__init__("set_stats_refs")
+    def __init__(self, cls):
+        super(SqlSetStatsRefs, self).__init__("set_stats_refs")
 
-    self.cls = cls
+        self.cls = cls
 
-  def generate(self):
-    table = self.cls.sqlmeta.table
+    def generate(self):
+        table = self.cls.sqlmeta.table
 
-    return """
-      update %s
-      set stats_curr_id = %%(statsId)s, stats_prev_id = stats_curr_id
-      where id = %%(id)s
-    """ % table
+        return """
+            update %s
+            set stats_curr_id = %%(statsId)s, stats_prev_id = stats_curr_id
+            where id = %%(id)s
+        """ % table
 
 class SqlInsert(SqlOperation):
-  def __init__(self, cls, attrs):
-    super(SqlInsert, self).__init__("insert")
+    def __init__(self, cls, attrs):
+        super(SqlInsert, self).__init__("insert")
 
-    self.cls = cls
-    self.attrs = attrs
+        self.cls = cls
+        self.attrs = attrs
 
-  def generate(self):
-    table = self.cls.sqlmeta.table
+    def generate(self):
+        table = self.cls.sqlmeta.table
 
-    cols = list()
-    vals = list()
+        cols = list()
+        vals = list()
 
-    for name in self.attrs:
-      cols.append(transformColumn(name))
-      vals.append("%%(%s)s" % name)
+        for name in self.attrs:
+            cols.append(transform_column(name))
+            vals.append("%%(%s)s" % name)
 
-    colsSql = ", ".join(cols)
-    valsSql = ", ".join(vals)
+        colsSql = ", ".join(cols)
+        valsSql = ", ".join(vals)
 
-    insert = "insert into %s (%s) values (%s)" % (table, colsSql, valsSql)
-    select = "select currval('%s_id_seq')" % table
+        insert = "insert into %s (%s) values (%s)" % (table, colsSql, valsSql)
+        select = "select currval('%s_id_seq')" % table
 
-    sql = "%s; %s" % (insert, select)
+        sql = "%s; %s" % (insert, select)
 
-    return sql
+        return sql
 
 class SqlUpdate(SqlOperation):
-  def __init__(self, cls, attrs):
-    super(SqlUpdate, self).__init__("update")
+    def __init__(self, cls, attrs):
+        super(SqlUpdate, self).__init__("update")
 
-    self.cls = cls
-    self.attrs = attrs
+        self.cls = cls
+        self.attrs = attrs
 
-  def generate(self):
-    table = self.cls.sqlmeta.table
+    def generate(self):
+        table = self.cls.sqlmeta.table
 
-    elems = list()
+        elems = list()
 
-    for name in self.attrs:
-      elems.append("%s = %%(%s)s" % (transformColumn(name), name))
-    
-    elemsSql = ", ".join(elems)
+        for name in self.attrs:
+            elems.append("%s = %%(%s)s" % (transform_column(name), name))
+        
+        elemsSql = ", ".join(elems)
 
-    sql = "update %s set %s where id = %%(id)s" % (table, elemsSql)
+        sql = "update %s set %s where id = %%(id)s" % (table, elemsSql)
 
-    return sql
+        return sql
 
 class SqlExpire(SqlOperation):
-  def __init__(self, cls, keepCurrStats):
-    super(SqlExpire, self).__init__("expire")
+    def __init__(self, cls, keep_curr_stats):
+        super(SqlExpire, self).__init__("expire")
 
-    self.cls = cls
-    self.keepCurrStats = keepCurrStats
+        self.cls = cls
+        self.keep_curr_stats = keep_curr_stats
 
-  def generate(self):
-    table = self.cls.sqlmeta.table
+    def generate(self):
+        table = self.cls.sqlmeta.table
 
-    if table.endswith("_stats"):
-      parent_table = table[0:table.find("_stats")]
-      sql = """
-        delete from %s 
-        where qmf_update_time < now() - interval '%%(threshold)s seconds'
-      """ % (table)
-      if self.keepCurrStats:
-        sql += " and id not in (select stats_curr_id from %s)" % (parent_table)
-    else:
-      sql = """
-        delete from %s
-        where qmf_delete_time < now() - interval '%%(threshold)s seconds'
-        and qmf_persistent = 'f'
-      """ % (table)
+        if table.endswith("_stats"):
+            parent_table = table[0:table.find("_stats")]
+            sql = """
+                delete from %s 
+                where qmf_update_time < now() - interval '%%(threshold)s seconds'
+            """ % table
+            if self.keep_curr_stats:
+                sql += " and id not in (select stats_curr_id from %s)" \
+                    % parent_table
+        else:
+            sql = """
+                delete from %s
+                where qmf_delete_time < now() - interval '%%(threshold)s seconds'
+                and qmf_persistent = 'f'
+            """ % table
 
-    return sql
+        return sql
 
 class SqlProfile(object):
-  def __init__(self):
-    self.ops = list()
-    self.commitTime = 0.0
+    def __init__(self):
+        self.ops = list()
+        self.commit_time = 0.0
 
-  def report(self):
-    timesByKey = dict()
+    def report(self):
+        times_by_key = dict()
 
-    executeTime = 0.0
+        execute_time = 0.0
 
-    for op in self.ops:
-      if op.time is not None:
-        executeTime += op.time
+        for op in self.ops:
+            if op.time is not None:
+                execute_time += op.time
 
-      try:
-        times = timesByKey[op.key()]
+            try:
+                times = times_by_key[op.key()]
 
-        if op.time is not None:
-          times.append(op.time)
-      except KeyError:
-        if op.time is not None:
-          timesByKey[op.key()] = list((op.time,))
+                if op.time is not None:
+                    times.append(op.time)
+            except KeyError:
+                if op.time is not None:
+                    times_by_key[op.key()] = list((op.time,))
 
-    fmt = "%-40s %9.2f %9.2f %6i"
-    records = list()
+        fmt = "%-40s %9.2f %9.2f %6i"
+        records = list()
 
-    for key, values in timesByKey.items():
-      count = len(values)
-      ttime = sum(values) * 1000
-      atime = ttime / float(count)
+        for key, values in times_by_key.items():
+            count = len(values)
+            ttime = sum(values) * 1000
+            atime = ttime / float(count)
 
-      records.append((key, ttime, atime, count))
+            records.append((key, ttime, atime, count))
 
-    print
+        print
 
-    srecords = sorted(records, key=lambda x: x[1], reverse=True)
+        srecords = sorted(records, key=lambda x: x[1], reverse=True)
 
-    for i, rec in enumerate(srecords):
-      print fmt % rec
+        for i, rec in enumerate(srecords):
+            print fmt % rec
 
-      if i >= 10:
-        break
+            if i >= 10:
+                break
 
-    print
+        print
 
-    srecords = sorted(records, key=lambda x: x[2], reverse=True)
+        srecords = sorted(records, key=lambda x: x[2], reverse=True)
 
-    for i, rec in enumerate(srecords):
-      print fmt % rec
+        for i, rec in enumerate(srecords):
+            print fmt % rec
 
-      if i >= 10:
-        break
+            if i >= 10:
+                break
 
-    print
-    print "Total statement execute time: %9.3f seconds" % executeTime
-    print "Total commit time:            %9.3f seconds" % self.commitTime
+        print
+        print "Total statement execute time: %9.3f seconds" % execute_time
+        print "Total commit time:            %9.3f seconds" % self.commit_time
 
 
 class SqlAgentDisconnect(SqlOperation):
-  def __init__(self, agent):
-    super(SqlAgentDisconnect, self).__init__("disconnect_agent")
-    self.agent = agent
+    def __init__(self, agent):
+        super(SqlAgentDisconnect, self).__init__("disconnect_agent")
+        self.agent = agent
 
-  def generate(self):
-    sql = ""
-    for cls in mint.schema.entityClasses:
-      sql += """
-       update %s
-         set qmf_delete_time = now()
-       where qmf_persistent = 'f'
-         and qmf_delete_time is null""" % (dbStyle.pythonClassToDBTable(cls))
-      if self.agent:
-        sql += """
-         and qmf_agent_id = %(qmf_agent_id)s;
-        """
-      else:
-        sql += """;
-        """
-    return sql
+    def generate(self):
+        sql = ""
+        for cls in mint.schema.entityClasses:
+            sql += """
+             update %s
+                 set qmf_delete_time = now()
+             where qmf_persistent = 'f'
+                 and qmf_delete_time is null""" % (dbStyle.pythonClassToDBTable(cls))
+            if self.agent:
+                sql += """
+                 and qmf_agent_id = %(qmf_agent_id)s;
+                """
+            else:
+                sql += """;
+                """
+        return sql

Modified: mgmt/trunk/mint/python/mint/tools.py
===================================================================
--- mgmt/trunk/mint/python/mint/tools.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/tools.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -155,8 +155,8 @@
             enable_logging("mint", "debug", sys.stderr)
 
         app = Mint(self.config)
-        app.updateEnabled = False
-        app.expireEnabled = False
+        app.update_enabled = False
+        app.expire_enabled = False
 
         self.database = MintDatabase(app)
         self.database.check()
@@ -195,13 +195,13 @@
 
     class LoadSchema(Command):
         def run(self, opts, args):
-            self.parent.database.loadSchema()
+            self.parent.database.load_schema()
             print "The schema is loaded"
 
     class DropSchema(Command):
         def run(self, opts, args):
             if "force" in opts:
-                self.parent.database.dropSchema()
+                self.parent.database.drop_schema()
                 print "The schema is dropped"
             else:
                 raise CommandException \
@@ -210,8 +210,8 @@
     class ReloadSchema(Command):
         def run(self, opts, args):
             if "force" in opts:
-                self.parent.database.dropSchema()
-                self.parent.database.loadSchema()
+                self.parent.database.drop_schema()
+                self.parent.database.load_schema()
                 print "The schema is reloaded"
             else:
                 raise CommandException \
@@ -219,7 +219,7 @@
 
     class CheckSchema(Command):
         def run(self, opts, args):
-            self.parent.database.checkSchema()
+            self.parent.database.check_schema()
 
     class AddUser(Command):
         def run(self, opts, args):
@@ -471,7 +471,7 @@
 
                     sleep(1)
 
-                    stats = app.updateThread.stats
+                    stats = app.update_thread.stats
 
                     enq = stats.enqueued
                     deq = stats.dequeued

Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/update.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -24,7 +24,7 @@
         self.updates = UpdateQueue(slotCount=2)
 
     def init(self):
-        self.conn = self.app.database.getConnection()
+        self.conn = self.app.database.get_connection()
         self.stats = UpdateStats()
 
     def enqueue(self, update):
@@ -42,7 +42,7 @@
 
     def run(self):
         while True:
-            if self.stopRequested:
+            if self.stop_requested:
                 break
 
             try:

Modified: mgmt/trunk/mint/python/mint/util.py
===================================================================
--- mgmt/trunk/mint/python/mint/util.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/util.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -15,21 +15,21 @@
 log = logging.getLogger("mint.util")
 
 class MintDaemonThread(Thread):
-  def __init__(self, app):
-    super(MintDaemonThread, self).__init__()
+    def __init__(self, app):
+        super(MintDaemonThread, self).__init__()
 
-    self.app = app
+        self.app = app
 
-    self.stopRequested = False
+        self.stop_requested = False
 
-    self.setDaemon(True)
+        self.setDaemon(True)
 
-  def init(self):
-    pass
+    def init(self):
+        pass
 
-  def stop(self):
-    assert self.stopRequested is False
-    self.stopRequested = True
+    def stop(self):
+        assert self.stop_requested is False
+        self.stop_requested = True
 
 def prompt_password():
     password = None
@@ -46,72 +46,72 @@
     return password
 
 class QmfAgentId(object):
-  def __init__(self, brokerId, brokerBank, agentBank):
-    assert brokerId
+    def __init__(self, brokerId, brokerBank, agentBank):
+        assert brokerId
 
-    self.brokerId = brokerId
-    self.brokerBank = brokerBank
-    self.agentBank = agentBank
+        self.brokerId = brokerId
+        self.brokerBank = brokerBank
+        self.agentBank = agentBank
 
-  def fromObject(cls, object):
-    broker = object.getBroker()
+    def fromObject(cls, object):
+        broker = object.getBroker()
 
-    brokerId = broker.getBrokerId()
-    brokerBank = broker.getBrokerBank()
-    agentBank = object.getObjectId().getAgentBank()
+        brokerId = broker.getBrokerId()
+        brokerBank = broker.getBrokerBank()
+        agentBank = object.getObjectId().getAgentBank()
 
-    return cls(brokerId, brokerBank, agentBank)
+        return cls(brokerId, brokerBank, agentBank)
 
-  def fromAgent(cls, agent):
-    broker = agent.getBroker()
+    def fromAgent(cls, agent):
+        broker = agent.getBroker()
 
-    brokerId = broker.getBrokerId()
-    brokerBank = broker.getBrokerBank()
-    agentBank = agent.getAgentBank()
+        brokerId = broker.getBrokerId()
+        brokerBank = broker.getBrokerBank()
+        agentBank = agent.getAgentBank()
 
-    return cls(brokerId, brokerBank, agentBank)
+        return cls(brokerId, brokerBank, agentBank)
 
-  def fromString(cls, string):
-    brokerId, brokerBank, agentBank = string.split(".")
+    def fromString(cls, string):
+        brokerId, brokerBank, agentBank = string.split(".")
 
-    brokerBank = int(brokerBank)
-    agentBank = int(agentBank)
+        brokerBank = int(brokerBank)
+        agentBank = int(agentBank)
 
-    return cls(brokerId, brokerBank, agentBank)
+        return cls(brokerId, brokerBank, agentBank)
 
-  fromObject = classmethod(fromObject)
-  fromAgent = classmethod(fromAgent)
-  fromString = classmethod(fromString)
+    fromObject = classmethod(fromObject)
+    fromAgent = classmethod(fromAgent)
+    fromString = classmethod(fromString)
 
-  def __str__(self):
-    return "%s.%i.%i" % (self.brokerId, self.brokerBank, self.agentBank)
+    def __str__(self):
+        return "%s.%i.%i" % (self.brokerId, self.brokerBank, self.agentBank)
 
 class QmfObjectId(object):
-  def __init__(self, first, second):
-    self.first = first
-    self.second = second
+    def __init__(self, first, second):
+        self.first = first
+        self.second = second
 
-  def fromObject(cls, object):
-    oid = object.getObjectId()
+    def fromObject(cls, object):
+        oid = object.getObjectId()
 
-    return cls(oid.first, oid.second)
+        return cls(oid.first, oid.second)
 
-  def fromString(cls, string):
-    first, second = string.split(".")
+    def fromString(cls, string):
+        first, second = string.split(".")
 
-    first = int(first)
-    second = int(second)
+        first = int(first)
+        second = int(second)
 
-    return cls(first, second)
+        return cls(first, second)
 
-  fromObject = classmethod(fromObject)
-  fromString = classmethod(fromString)
+    fromObject = classmethod(fromObject)
+    fromString = classmethod(fromString)
 
-  def toObjectId(self):
-    return ObjectId(None, self.first, self.second)
+    def toObjectId(self):
+        return ObjectId(None, self.first, self.second)
 
-  def __str__(self):
-    return "%i.%i" % (self.first, self.second)
+    def __str__(self):
+        return "%i.%i" % (self.first, self.second)
 
 password_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
 

Modified: mgmt/trunk/mint/python/mint/vacuum.py
===================================================================
--- mgmt/trunk/mint/python/mint/vacuum.py	2010-01-12 11:36:02 UTC (rev 3789)
+++ mgmt/trunk/mint/python/mint/vacuum.py	2010-01-12 21:47:25 UTC (rev 3790)
@@ -6,11 +6,11 @@
 class VacuumThread(MintDaemonThread):
   def run(self):
     while True:
-      if self.stopRequested:
+      if self.stop_requested:
         break
 
       up = VacuumUpdate()
-      self.app.updateThread.enqueue(up)
+      self.app.update_thread.enqueue(up)
 
       sleep(60 * 10)
 



More information about the rhmessaging-commits mailing list