BIND 10 trac963, updated. a7254a232bedb445f4c7dd47b8f623a94f7056b1 [963] addressed review comments

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Mar 26 14:09:42 UTC 2012


The branch, trac963 has been updated
       via  a7254a232bedb445f4c7dd47b8f623a94f7056b1 (commit)
      from  46f994f729d0f554ad4f58abc82acbc7b526ffc5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a7254a232bedb445f4c7dd47b8f623a94f7056b1
Author: Jelte Jansen <jelte at isc.org>
Date:   Mon Mar 26 16:08:39 2012 +0200

    [963] addressed review comments
    
    documentation changes
    different exit status on uncaught exceptions
    removed unused log message
    updated 'corrupt' log message
    improved 'quiet' test case

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dbutil/b10-dbutil.8            |    4 +-
 src/bin/dbutil/b10-dbutil.xml          |    5 ++-
 src/bin/dbutil/dbutil.py.in            |   35 +++++++++++++++++++++-----------
 src/bin/dbutil/dbutil_messages.mes     |    5 +---
 src/bin/dbutil/tests/dbutil_test.sh.in |    2 +-
 5 files changed, 30 insertions(+), 21 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dbutil/b10-dbutil.8 b/src/bin/dbutil/b10-dbutil.8
index ff7a2e5..437a69d 100644
--- a/src/bin/dbutil/b10-dbutil.8
+++ b/src/bin/dbutil/b10-dbutil.8
@@ -44,7 +44,7 @@ utility is a general administration utility for SQL databases\&. (Currently only
 \fBb10\-dbutil\fR
 operates in one of two modes, check mode or upgrade mode\&.
 .PP
-In check mode (\fBb10\-dbutil \-\-check\fR), the utility reads the version of the database schema from the database and prints it\&. It will tell you whether the schema is at the latest version supported by BIND 10\&. Exit status is 0 if the schema is at the correct version, 1 if the schema is at an older version, 2 if the schema is at a version not yet supported by this version of b10\-dbutil\&. Any higher value indicates a read or command\-line error\&.
+In check mode (\fBb10\-dbutil \-\-check\fR), the utility reads the version of the database schema from the database and prints it\&. It will tell you whether the schema is at the latest version supported by BIND 10\&. Exit status is 0 if the schema is at the correct version, 1 if the schema is at an older version, 2 if the schema is at a version not yet supported by this version of b10\-dbutil\&. Any higher value indicates an error during command\-line parsing or execution\&.
 .PP
 When the upgrade function is selected (\fBb10\-dbutil \-\-upgrade\fR), the utility takes a copy of the database, then upgrades it to the latest version of the schema\&. The contents of the database remain intact\&. (The backup file is a file in the same directory as the database file\&. It has the same name, with "\&.backup" appended to it\&. If a file of that name already exists, the file will have the suffix "\&.backup\-1"\&. If that exists, the file will be suffixed "\&.backup\-2", and so on)\&. Exit status is 0 if the upgrade is either succesful or aborted by the user, and non\-zero if there is an error\&.
 .PP
@@ -74,7 +74,7 @@ The upgrade function will upgrade a BIND 10 database \- no matter how old the sc
 .PP
 \fB\-\-verbose\fR
 .RS 4
-Enable verbose mode\&. Each SQL command issued by the utility will be printed to stdout before it is executed\&.
+Enable verbose mode\&. Each SQL command issued by the utility will be printed to stderr before it is executed\&.
 .RE
 .PP
 \fB\-\-quiet\fR
diff --git a/src/bin/dbutil/b10-dbutil.xml b/src/bin/dbutil/b10-dbutil.xml
index d1ce2fc..c1c0dee 100644
--- a/src/bin/dbutil/b10-dbutil.xml
+++ b/src/bin/dbutil/b10-dbutil.xml
@@ -78,7 +78,8 @@
       version supported by BIND 10. Exit status is 0 if the schema is at
       the correct version, 1 if the schema is at an older version, 2 if
       the schema is at a version not yet supported by this version of
-      b10-dbutil. Any higher value indicates a read or command-line error.
+      b10-dbutil. Any higher value indicates an error during command-line
+      parsing or execution.
     </para>
 
     <para>
@@ -159,7 +160,7 @@
         </term>
         <listitem>
           <para>Enable verbose mode.  Each SQL command issued by the
-          utility will be printed to stdout before it is executed.</para>
+          utility will be printed to stderr before it is executed.</para>
         </listitem>
       </varlistentry>
 
diff --git a/src/bin/dbutil/dbutil.py.in b/src/bin/dbutil/dbutil.py.in
index a5e12ad..81f351e 100755
--- a/src/bin/dbutil/dbutil.py.in
+++ b/src/bin/dbutil/dbutil.py.in
@@ -34,7 +34,27 @@ The is the database name with ".backup" appended to it (or ".backup-n" if
 upgrade fails.
 """
 
+# Exit codes
+# These are defined here because one of them is already used before most
+# of the import statements.
+EXIT_SUCCESS = 0
+EXIT_NEED_UPDATE = 1
+EXIT_VERSION_TOO_HIGH = 2
+EXIT_COMMAND_ERROR = 3
+EXIT_READ_ERROR = 4
+EXIT_UPGRADE_ERROR = 5
+EXIT_UNCAUGHT_EXCEPTION = 6
+
 import sys; sys.path.append("@@PYTHONPATH@@")
+
+# Normally, python exits with a status code of 1 on uncaught exceptions
+# Since we reserve exit status 1 for 'database needs upgrade', we
+# override the excepthook to exit with a different status
+def my_except_hook(a, b, c):
+    sys.__excepthook__(a,b,c)
+    sys.exit(EXIT_UNCAUGHT_EXCEPTION)
+sys.excepthook = my_except_hook
+
 import os, sqlite3, shutil
 from optparse import OptionParser
 import isc.util.process
@@ -47,20 +67,13 @@ isc.util.process.rename()
 
 TRACE_BASIC = logger.DBGLVL_TRACE_BASIC
 
+
 # @brief Version String
 # This is the version displayed to the user.  It comprises the module name,
 # the module version number, and the overall BIND 10 version number (set in
 # configure.ac)
 VERSION = "b10-dbutil 20120319 (BIND 10 @PACKAGE_VERSION@)"
 
-# Exit codes
-EXIT_SUCCESS = 0
-EXIT_NEED_UPDATE = 1
-EXIT_VERSION_TOO_HIGH = 2
-EXIT_COMMAND_ERROR = 3
-EXIT_READ_ERROR = 4
-EXIT_UPGRADE_ERROR = 5
-
 # @brief Statements to Update the Database
 # These are in the form of a list of dictionaries, each of which contains the
 # information to perform an incremental upgrade from one version of the
@@ -585,13 +598,11 @@ if __name__ == "__main__":
         except Exception as ex:
             if in_progress:
                 logger.error(DBUTIL_UPGRADE_FAILED, ex)
-                logger.warn(DBUTIL_DATABASE_MAY_BE_CORRUPTED)
+                logger.warn(DBUTIL_DATABASE_MAY_BE_CORRUPT, db.db_file,
+                            db.backup_file)
             else:
                 logger.error(DBUTIL_UPGRADE_PREPARATION_FAILED, ex)
                 logger.info(DBUTIL_UPGRADE_NOT_ATTEMPTED)
             exit_code = EXIT_UPGRADE_ERROR
-    else:
-        logger.error(DBUTIL_NO_ACTION_SPECIFIED)
-        exit_code = EXIT_COMMAND_ERROR
 
     sys.exit(exit_code)
diff --git a/src/bin/dbutil/dbutil_messages.mes b/src/bin/dbutil/dbutil_messages.mes
index f5496b0..90ede92 100644
--- a/src/bin/dbutil/dbutil_messages.mes
+++ b/src/bin/dbutil/dbutil_messages.mes
@@ -47,7 +47,7 @@ provided.
 b10-dbutil was called with both the commands --upgrade and --check. Only one
 action can be performed at a time.
 
-% DBUTIL_DATABASE_MAY_BE_CORRUPTED database may be corrupt, restore it from backup
+% DBUTIL_DATABASE_MAY_BE_CORRUPT database file %1 may be corrupt, restore it from backup (%2)
 The upgrade failed while it was in progress; the database may now be in an
 inconsistent state, and it is advised to restore it from the backup that was
 created when b10-dbutil started.
@@ -58,9 +58,6 @@ Debug message; the given SQL statement is executed
 % DBUTIL_FILE Database file: %1
 The database file that is being checked.
 
-% DBUTIL_NO_ACTION_SPECIFIED Command error: neither --check nor --upgrade selected
-b10-dbutil was called without either --check or --upgrade.
-
 % DBUTIL_NO_FILE must supply name of the database file to upgrade
 b10-dbutil was called without a database file. Currently, it cannot find this
 file on its own, and it must be provided.
diff --git a/src/bin/dbutil/tests/dbutil_test.sh.in b/src/bin/dbutil/tests/dbutil_test.sh.in
index 393d6e0..92c5953 100755
--- a/src/bin/dbutil/tests/dbutil_test.sh.in
+++ b/src/bin/dbutil/tests/dbutil_test.sh.in
@@ -445,7 +445,7 @@ rm -f $tempfile $backupfile
 
 echo "13.3 quiet flag"
 copy_file $testdata/old_v1.sqlite3 $tempfile
-../run_dbutil.sh --check --quiet $tempfile 2>&1 | grep dbutil
+../run_dbutil.sh --check --quiet $tempfile 2>&1 | grep .
 failzero $?
 rm -f $tempfile $backupfile
 



More information about the bind10-changes mailing list