Author: tmckay
Date: 2011-11-09 20:30:18 +0000 (Wed, 09 Nov 2011)
New Revision: 5127
Modified:
trunk/cumin/bin/cumin-admin
trunk/cumin/bin/cumin-data
trunk/cumin/bin/cumin-web
trunk/cumin/python/cumin/admin.py
Log:
Tweaks to error checking after testing latest commits
Modified: trunk/cumin/bin/cumin-admin
===================================================================
--- trunk/cumin/bin/cumin-admin 2011-11-09 19:36:31 UTC (rev 5126)
+++ trunk/cumin/bin/cumin-admin 2011-11-09 20:30:18 UTC (rev 5127)
@@ -6,7 +6,7 @@
import subprocess
from subprocess import PIPE
-from psycopg2 import IntegrityError, OperationalError
+from psycopg2 import IntegrityError, OperationalError, ProgrammingError
home = os.environ.get("CUMIN_HOME",
os.path.normpath("/usr/share/cumin"))
sys.path.append(os.path.join(home, "python"))
@@ -232,8 +232,8 @@
print "This version of cumin-admin can upgrade the schema to version
%s" % target
print "The schema version is already %s" % curr
print "Have you been using a newer version of cumin?"
- print "In order to use this version of cumin you will have to recreate the
schema"
-
+ print "You will have to recreate the schema with "\
+ "'cumin-admin drop-schema' and 'cumin-admin
create-schema'"
else:
print "Attempting to upgrade the schema from %s to %s" % (curr,
target)
upgrade_dir = os.path.join(app.home, "model/upgrades")
@@ -242,6 +242,8 @@
if not upgrade_path:
print "Could not find an upgrade path from %s to %s in %s" % \
(curr, target, upgrade_dir)
+ print "You will have to recreate the schema with "\
+ "'cumin-admin drop-schema' and 'cumin-admin
create-schema'"
else:
if not confirm("Found an update path. Alter the schema?", True):
@@ -272,7 +274,10 @@
print "Upgrade to schema version %s succeeded" % target
def handle_create_schema(app, cursor, opts, args):
- app.admin.create_schema(cursor)
+ try:
+ app.admin.create_schema(cursor)
+ except ProgrammingError:
+ error("The schema already exists")
app.admin.add_role(cursor, "user")
app.admin.add_role(cursor, "admin")
@@ -284,9 +289,9 @@
schema_version = app.admin.check_schema(cursor)
except SchemaMissing:
error("The schema is missing, run 'cumin-admin
create-schema'")
- except Exception, e:
- error(str(e))
-
+ except SchemaVersion, e:
+ error(str(e) + ", run 'cumin-admin upgrade-schema'")
+
print "The schema is OK (schema version %s)" % schema_version
def handle_drop_schema(app, cursor, opts, args):
Modified: trunk/cumin/bin/cumin-data
===================================================================
--- trunk/cumin/bin/cumin-data 2011-11-09 19:36:31 UTC (rev 5126)
+++ trunk/cumin/bin/cumin-data 2011-11-09 20:30:18 UTC (rev 5127)
@@ -148,9 +148,6 @@
# Get options
opts, args = parser.parse_args()
- if len(args) != 0:
- log.error("Extra arguments:" + "".join([" "+arg
for arg in args]))
- raise EarlyReturn
# --section controls which section is read from the config file
# If a section other than "data" is specified, require it to exist
@@ -167,6 +164,10 @@
values.log_max_mb,
values.log_max_archives)
+ if len(args) != 0:
+ log.error("Extra arguments:" + "".join([" "+arg
for arg in args]))
+ raise EarlyReturn
+
model_dir = os.path.join(config.home, "model")
broker_uris = [x.strip() for x in opts.brokers.split(",")]
@@ -232,13 +233,11 @@
except KeyboardInterrupt:
log.info("Received SIGINT")
- except SystemExit:
+ except (SystemExit, EarlyReturn):
if "--help" not in sys.argv:
+ log.error("Error in options, arguments, or config values")
return_code = 1
- except EarlyReturn:
- return_code = 1
-
except OperationalError:
# Failed to talk to the database on check()
log.info("Run 'cumin-database check' as root for more
information.")
Modified: trunk/cumin/bin/cumin-web
===================================================================
--- trunk/cumin/bin/cumin-web 2011-11-09 19:36:31 UTC (rev 5126)
+++ trunk/cumin/bin/cumin-web 2011-11-09 20:30:18 UTC (rev 5127)
@@ -103,9 +103,6 @@
# Get options
opts, args = parser.parse_args()
- if len(args) != 0:
- log.error("Extra arguments:" + "".join([" "+arg
for arg in args]))
- raise EarlyReturn
# --section controls which section is read from the config file
# If a section other than "web" is specified, require it to exist
@@ -122,6 +119,10 @@
values.log_max_mb,
values.log_max_archives)
+ if len(args) != 0:
+ log.error("Extra arguments:" + "".join([" "+arg
for arg in args]))
+ raise EarlyReturn
+
broker_uris = [x.strip() for x in opts.brokers.split(",")]
authmech = [x.strip() for x in values.auth.split(";")]
cumin = Cumin(config.get_home(), broker_uris, opts.database,
@@ -165,8 +166,9 @@
log.info("Received SIGINT")
pass
- except SystemExit:
+ except (SystemExit, EarlyReturn):
if "--help" not in sys.argv:
+ log.error("Error in options, arguments, or config values")
return_code = 1
except EarlyReturn:
Modified: trunk/cumin/python/cumin/admin.py
===================================================================
--- trunk/cumin/python/cumin/admin.py 2011-11-09 19:36:31 UTC (rev 5126)
+++ trunk/cumin/python/cumin/admin.py 2011-11-09 20:30:18 UTC (rev 5127)
@@ -64,7 +64,7 @@
if info.schema_version != schema_version:
args = (schema_version, info.schema_version)
- msg = "Expected schema version %s; found version %s" % args
+ msg = "Expected schema version %s, found version %s" % args
raise SchemaVersion(msg)
return info.schema_version