Changeset: de8fed4558e8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=de8fed4558e8
Modified Files:
        clients/python/monetdb/control.py
        clients/python/test/control.py
        configure.ag
        sql/backends/monet5/datacell/Makefile.ag
Branch: xid
Log Message:

Merge with default branch.


diffs (268 lines):

diff --git a/clients/python/monetdb/control.py 
b/clients/python/monetdb/control.py
--- a/clients/python/monetdb/control.py
+++ b/clients/python/monetdb/control.py
@@ -6,7 +6,7 @@ def parse_statusline(line):
     info = {}
     info['path'] = split[0]
     info['name'] = info['path'].split("/")[-1]
-    info['locked'] = True if split[1] == ("1") else False
+    info['locked'] = split[1] == ("1")
     info['state'] = int(split[2])
     info['scenarios'] = split[3].split("'")
     info['connections'] = split[4].split("'")
@@ -18,12 +18,16 @@ def parse_statusline(line):
     info['min_uptime'] = int(split[10])
     info['last_crash'] = int(split[11])
     info['lastStart'] = int(split[12])
-    info['crash_avg1'] = True if split[1] == ("1") else False
+    info['crash_avg1'] = split[1] == ("1")
     info['crash_avg10'] = float(split[14])
     info['crash_avg30'] = float(split[15])
     return info
 
 class Control:
+    """
+    Use this module to manage your MonetDB databases. You can create, start, 
stop,
+    lock, unlock, destroy your databases and request status information.
+    """
     def __init__(self, hostname, port, passphrase):
         self.server = mapi.Server()
         self.server.connect(hostname, port, 'monetdb', passphrase, 
'merovingian', 'control')
@@ -32,38 +36,87 @@ class Control:
         return self.server.cmd("%s %s\n" % (database_name, command))
 
     def create(self, database_name):
+        """
+        Initialises a new database or multiplexfunnel in the MonetDB Server.
+        A database created with this command makes it available  for use,
+        however in maintenance mode (see monetdb lock).
+        """
         return self._send_command(database_name, "create")
 
     def destroy(self, database_name):
+        """
+        Removes the given database, including all its data and
+        logfiles.  Once destroy has completed, all data is lost.
+        Be careful when using this command.
+        """
         return self._send_command(database_name, "destroy")
 
     def lock(self, database_name):
+        """
+        Puts the given database in maintenance mode.  A database
+        under maintenance can only be connected to by the DBA.
+        A database which is under maintenance is not started
+        automatically.  Use the "release" command to bring
+        the database back for normal usage.
+        """
         return self._send_command(database_name, "lock")
 
     def release(self, database_name):
+        """
+        Brings back a database from maintenance mode.  A released
+        database is available again for normal use.  Use the
+        "lock" command to take a database under maintenance.
+        """
         return self._send_command(database_name, "release")
 
-    def status(self, database_name):
-        raw = self._send_command(database_name, "status")
-        return parse_statusline(raw)
-
-    def statuses(self):
-        raw = self._send_command("#all", "status")
-        return [parse_statusline(line) for line in raw.split("\n")]
+    def status(self, database_name=False):
+        """
+        Shows the state of a given glob-style database match, or
+        all known if none given.  Instead of the normal mode, a
+        long and crash mode control what information is displayed.
+        """
+        if database_name:
+            raw = self._send_command(database_name, "status")
+            return parse_statusline(raw)
+        else:
+            raw = self._send_command("#all", "status")
+            return [parse_statusline(line) for line in raw.split("\n")]
 
     def start(self, database_name):
+        """
+        Starts the given database, if the MonetDB Database Server
+        is running.
+        """
         return self._send_command(database_name, "start")
 
     def stop(self, database_name):
+        """
+        Stops the given database, if the MonetDB Database Server
+        is running.
+        """
         return self._send_command(database_name, "stop")
 
     def kill(self, database_name):
+        """
+        Kills the given database, if the MonetDB Database Server
+        is running.  Note: killing a database should only be done
+        as last resort to stop a database.  A database being
+        killed may end up with data loss.
+        """
         return self._send_command(database_name, "kill")
 
     def set(self, database_name, property_, value):
+        """
+        sets property to value for the given database
+        for a list of properties, use `monetdb get all`
+        """
         return self._send_command(database_name, "%s=%s" % (property_, value))
 
     def get(self, database_name):
+        """
+        gets value for property for the given database, or
+        retrieves all properties for the given database
+        """
         properties = self._send_command(database_name, "get")
         values = {}
         for dirty_line in properties.split("\n"):
@@ -75,7 +128,17 @@ class Control:
         return values
 
     def inherit(self, database_name, property_):
+        """
+        unsets property, reverting to its inherited value from
+        the default configuration for the given database
+        """
         return self._send_command(database_name, property_ + "=")
 
-    def version(self, database_name):
-        self._send_command(database_name, "version")
\ No newline at end of file
+    def rename(self, old, new):
+        return self.set(old, "name", new)
+
+    def defaults(self):
+        return self.get("#defaults")
+
+    def neighbours(self):
+        return self._send_command("anelosimus", "eximius")
\ No newline at end of file
diff --git a/clients/python/test/control.py b/clients/python/test/control.py
--- a/clients/python/test/control.py
+++ b/clients/python/test/control.py
@@ -28,12 +28,8 @@ class TestManage(unittest.TestCase):
     def testCreate(self):
         create_name = database_prefix + "create"
         do_without_fail(lambda: self.control.destroy(create_name))
-
         self.control.create(create_name)
-        # can't create it again
         self.assertRaises(OperationalError, self.control.create, create_name)
-
-        # cleanup
         do_without_fail(lambda: self.control.destroy(create_name))
 
     def testDestroy(self):
@@ -54,7 +50,22 @@ class TestManage(unittest.TestCase):
         self.assertRaises(OperationalError, self.control.release, 
database_name)
 
     def testStatus(self):
-        self.control.status(database_name)
+        status1 = database_prefix + "status1"
+        do_without_fail(lambda: self.control.destroy(status1))
+        self.control.create(status1)
+        status = self.control.status(status1)
+        self.assertEquals(status["name"], status1)
+
+    def testStatuses(self):
+        status1 = database_prefix + "status1"
+        status2 = database_prefix + "status2"
+        do_without_fail(lambda: self.control.destroy(status1))
+        do_without_fail(lambda: self.control.destroy(status2))
+        self.control.create(status1)
+        self.control.create(status2)
+        statuses = self.control.status()
+        self.assertTrue(status1 in [status["name"] for status in statuses])
+        self.assertTrue(status2 in [status["name"] for status in statuses])
 
     def testStart(self):
         do_without_fail(lambda: self.control.stop(database_name))
@@ -83,8 +94,23 @@ class TestManage(unittest.TestCase):
         self.assertTrue(self.control.inherit(database_name, "readonly"))
         self.assertFalse(self.control.get(database_name).has_key("readonly"))
 
-    def testVersion(self):
-        self.control.version(database_name)
+    def testRename(self):
+        #return # this doesn't seem to work
+        old = database_prefix + "old"
+        new = database_prefix + "new"
+        do_without_fail(lambda: self.control.destroy(old))
+        self.control.create(old)
+        self.control.rename(old, new)
+        statuses = self.control.status()
+        self.assertTrue(new in [status["name"] for status in statuses])
+
+    def testDefaults(self):
+        defaults = self.control.defaults()
+        self.assertTrue(defaults.has_key("readonly"))
+
+    def testNeighbours(self):
+        neighbours = self.control.neighbours()
+        neighbours
 
 if __name__ == '__main__':
     unittest.main()
\ No newline at end of file
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -1110,7 +1110,7 @@ if test "x$have_perl" != xno; then
        esac
 else
        # no Perl implies no interpreter
-       PERL=`type -P false`
+       PERL=false
 fi
 
 AC_SUBST(PERL)
@@ -1178,7 +1178,7 @@ else
        have_python_libdir=no
        PYTHON_LIBDIR=""
        # and no interpreter
-       PYTHON=`type -P false`
+       PYTHON=false
 fi
 
 AC_SUBST(PYTHON)
@@ -1246,7 +1246,7 @@ else
        have_python3_libdir=no
        PYTHON3_LIBDIR=""
        # and no interpreter
-       PYTHON3=`type -P false`
+       PYTHON3=false
 fi
 
 AC_SUBST(PYTHON3)
diff --git a/sql/backends/monet5/datacell/Makefile.ag 
b/sql/backends/monet5/datacell/Makefile.ag
--- a/sql/backends/monet5/datacell/Makefile.ag
+++ b/sql/backends/monet5/datacell/Makefile.ag
@@ -51,18 +51,14 @@ lib__datacell = {
 bin_actuator = {
        SOURCES = actuator.c dcsocket.c
        LIBS = ../../../../common/stream/libstream \
-                  ../../../../common/options/libmoptions \
-                  ../../../../gdk/libbat \
-                  ../../../../monetdb5/tools/libmonetdb5
+               ../../../../gdk/libbat 
                
 }
 
 bin_sensor = {
        SOURCES = sensor.c dcsocket.c
        LIBS = ../../../../common/stream/libstream \
-                  ../../../../common/options/libmoptions \
-                  ../../../../gdk/libbat \
-                  ../../../../monetdb5/tools/libmonetdb5
+               ../../../../gdk/libbat 
 }
 
 scripts_mal = {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to