diff options
| author | Justin Bronn <jbronn@gmail.com> | 2009-04-20 00:11:36 +0000 |
|---|---|---|
| committer | Justin Bronn <jbronn@gmail.com> | 2009-04-20 00:11:36 +0000 |
| commit | dd51cf9876fb71db080aad767a386c0c3988b114 (patch) | |
| tree | c2b517a4e5c609ec15ee2d3d46332a9d03e3154d /django | |
| parent | 1c925f65b3f9ca126d97e8166557dc071177913a (diff) | |
[1.0.X] Fixed #10364 -- Correctly identify test spatial database creation errors to the user.
Backport of r10603 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10604 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/gis/db/backend/postgis/creation.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/django/contrib/gis/db/backend/postgis/creation.py b/django/contrib/gis/db/backend/postgis/creation.py index b404ac5e7c..163575c430 100644 --- a/django/contrib/gis/db/backend/postgis/creation.py +++ b/django/contrib/gis/db/backend/postgis/creation.py @@ -54,16 +54,19 @@ def _create_with_cursor(db_name, verbosity=1, autoclobber=False): cursor.execute(create_sql) #print create_sql except Exception, e: - # Drop and recreate, if necessary. - if not autoclobber: - confirm = raw_input("\nIt appears the database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % db_name) - if autoclobber or confirm == 'yes': - if verbosity >= 1: print 'Destroying old spatial database...' - drop_db(db_name) - if verbosity >= 1: print 'Creating new spatial database...' - cursor.execute(create_sql) + if 'already exists' in e.pgerror.lower(): + # Database already exists, drop and recreate if user agrees. + if not autoclobber: + confirm = raw_input("\nIt appears the database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % db_name) + if autoclobber or confirm == 'yes': + if verbosity >= 1: print 'Destroying old spatial database...' + drop_db(db_name) + if verbosity >= 1: print 'Creating new spatial database...' + cursor.execute(create_sql) + else: + raise Exception('Spatial Database Creation canceled.') else: - raise Exception('Spatial Database Creation canceled.') + raise Exception('Spatial database creation failed: "%s"' % e.pgerror.strip()) created_regex = re.compile(r'^createdb: database creation failed: ERROR: database ".+" already exists') def _create_with_shell(db_name, verbosity=1, autoclobber=False): |
