devtools/__init__.py
changeset 9886 1b26289217a3
parent 9864 f60a80592224
child 10038 f2f065d406dc
--- 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