# HG changeset patch # User Alain Leufroy # Date 1401791874 -7200 # Node ID 1b26289217a33cfaa2fd8c01fce22ad9f50bfa87 # Parent 9f546848ba48cd8ac8e2e76af62ca6517027c2d6 [devtools] improve error message when postgresql tools are missing By default in at least Debian, some pg tools are not present in the PATH. Or they may not be installed. But the tests tools expects them to be in the PATH, and give an unhelpful 'No such file or directory' backtrace if they're not found. To help devs using the pg tests we improve the error message. diff -r 9f546848ba48 -r 1b26289217a3 devtools/__init__.py --- a/devtools/__init__.py Fri Jul 11 17:13:32 2014 +0200 +++ b/devtools/__init__.py Tue Jun 03 12:37:54 2014 +0200 @@ -21,6 +21,7 @@ import os import sys +import errno import logging import shutil import pickle @@ -545,14 +546,29 @@ super(PostgresTestDataBaseHandler, self).__init__(*args, **kwargs) datadir = join(self.config.apphome, 'pgdb') if not exists(datadir): - subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C']) + try: + subprocess.check_call(['initdb', '-D', datadir, '-E', 'utf-8', '--locale=C']) + + except OSError, err: + if err.errno == errno.ENOENT: + raise OSError('"initdb" could not be found. ' + 'You should add the postgresql bin folder to your PATH ' + '(/usr/lib/postgresql/9.1/bin for example).') + raise port = self.system_source['db-port'] directory = self.system_source['db-host'] env = os.environ.copy() env['PGPORT'] = str(port) env['PGHOST'] = str(directory) - subprocess.check_call(['pg_ctl', 'start', '-w', '-D', datadir, '-o', '-h "" -k %s -p %s' % (directory, port)], - env=env) + try: + subprocess.check_call(['pg_ctl', 'start', '-w', '-D', datadir, '-o', '-h "" -k %s -p %s' % (directory, port)], + env=env) + except OSError, err: + if err.errno == errno.ENOENT: + raise OSError('"pg_ctl" could not be found. ' + 'You should add the postgresql bin folder to your PATH ' + '(/usr/lib/postgresql/9.1/bin for example).') + raise self.__CTL.add(datadir) @property