devtools/__init__.py
changeset 11029 c9d12d1d3081
parent 11017 3dfed980071c
child 11030 c1fdd22232d1
equal deleted inserted replaced
11028:66f94d7f9ca7 11029:c9d12d1d3081
   538 
   538 
   539 ### postgres test database handling ############################################
   539 ### postgres test database handling ############################################
   540 
   540 
   541 def startpgcluster(pyfile):
   541 def startpgcluster(pyfile):
   542     """Start a postgresql cluster next to pyfile"""
   542     """Start a postgresql cluster next to pyfile"""
   543     datadir = join(os.path.dirname(pyfile), 'data',
   543     datadir = join(os.path.dirname(pyfile), 'data', 'database',
   544                    'pgdb-%s' % os.path.splitext(os.path.basename(pyfile))[0])
   544                    'pgdb-%s' % os.path.splitext(os.path.basename(pyfile))[0])
   545     if not exists(datadir):
   545     if not exists(datadir):
   546         try:
   546         try:
   547             subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C'])
   547             subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C'])
   548 
   548 
   577         raise
   577         raise
   578 
   578 
   579 
   579 
   580 def stoppgcluster(pyfile):
   580 def stoppgcluster(pyfile):
   581     """Kill the postgresql cluster running next to pyfile"""
   581     """Kill the postgresql cluster running next to pyfile"""
   582     datadir = join(os.path.dirname(pyfile), 'data',
   582     datadir = join(os.path.dirname(pyfile), 'data', 'database',
   583                    'pgdb-%s' % os.path.splitext(os.path.basename(pyfile))[0])
   583                    'pgdb-%s' % os.path.splitext(os.path.basename(pyfile))[0])
   584     subprocess.call(['pg_ctl', 'stop', '-D', datadir, '-m', 'fast'])
   584     subprocess.call(['pg_ctl', 'stop', '-D', datadir, '-m', 'fast'])
   585     try:
   585     try:
   586         os.rmdir(DEFAULT_PSQL_SOURCES['system']['db-host'])
   586         os.rmdir(DEFAULT_PSQL_SOURCES['system']['db-host'])
   587     except OSError:
   587     except OSError: