Fixed #10364 -- Correctly identify test spatial database creation errors to the user.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10603 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
be11bd40d4
commit
bfe36750b1
|
@ -46,16 +46,19 @@ def _create_with_cursor(db_name, verbosity=1, autoclobber=False):
|
||||||
# Trying to create the database first.
|
# Trying to create the database first.
|
||||||
cursor.execute(create_sql)
|
cursor.execute(create_sql)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# Drop and recreate, if necessary.
|
if 'already exists' in e.pgerror.lower():
|
||||||
if not autoclobber:
|
# Database already exists, drop and recreate if user agrees.
|
||||||
confirm = raw_input("\nIt appears the database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % db_name)
|
if not autoclobber:
|
||||||
if autoclobber or confirm == 'yes':
|
confirm = raw_input("\nIt appears the database, %s, already exists. Type 'yes' to delete it, or 'no' to cancel: " % db_name)
|
||||||
if verbosity >= 1: print 'Destroying old spatial database...'
|
if autoclobber or confirm == 'yes':
|
||||||
drop_db(db_name)
|
if verbosity >= 1: print 'Destroying old spatial database...'
|
||||||
if verbosity >= 1: print 'Creating new spatial database...'
|
drop_db(db_name)
|
||||||
cursor.execute(create_sql)
|
if verbosity >= 1: print 'Creating new spatial database...'
|
||||||
|
cursor.execute(create_sql)
|
||||||
|
else:
|
||||||
|
raise Exception('Spatial database creation canceled.')
|
||||||
else:
|
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')
|
created_regex = re.compile(r'^createdb: database creation failed: ERROR: database ".+" already exists')
|
||||||
def _create_with_shell(db_name, verbosity=1, autoclobber=False):
|
def _create_with_shell(db_name, verbosity=1, autoclobber=False):
|
||||||
|
|
Loading…
Reference in New Issue