From d4fda0273580fc8575298614bc90569a73c1d5b3 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Tue, 17 Apr 2012 17:38:48 +0200 Subject: [PATCH] Avoid printing exception in db-setup If the db-setup is run multiple times without dropping the database, the attempt to set up version control again causes an exception. Since this is an expected condition, just print a message and exit normally. Signed-off-by: Zane Bitter --- bin/heat-db-setup-fedora | 2 +- heat/db/sqlalchemy/manage.py | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/heat-db-setup-fedora b/bin/heat-db-setup-fedora index 6153f535..00cb4785 100755 --- a/bin/heat-db-setup-fedora +++ b/bin/heat-db-setup-fedora @@ -221,7 +221,7 @@ else pushd /usr/lib/python2.7/site-packages/heat-0.0.1-py2.7.egg/heat/db/sqlalchemy/ fi -python migrate_repo/manage.py version_control mysql://heat:heat@localhost/heat migrate_repo +python manage.py version_control python manage.py upgrade popd diff --git a/heat/db/sqlalchemy/manage.py b/heat/db/sqlalchemy/manage.py index 489f24e9..4dffe783 100644 --- a/heat/db/sqlalchemy/manage.py +++ b/heat/db/sqlalchemy/manage.py @@ -1,6 +1,10 @@ #!/usr/bin/env python from migrate.versioning.shell import main +import migrate.exceptions if __name__ == '__main__': - main(url='mysql://heat:heat@localhost/heat', debug='False', - repository='migrate_repo') + try: + main(url='mysql://heat:heat@localhost/heat', debug='False', + repository='migrate_repo') + except migrate.exceptions.DatabaseAlreadyControlledError: + print 'Database already version controlled.' -- 2.45.2