[devtools] delete postgresql socket directory after killing the server
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 16 Oct 2015 16:44:36 +0200
changeset 10796 26a36c2a5fbd
parent 10795 839ea43f4d5b
child 10797 b4f8c0b98c29
[devtools] delete postgresql socket directory after killing the server ... or when failing to start it.
devtools/__init__.py
--- a/devtools/__init__.py	Mon Jul 27 10:13:25 2015 +0200
+++ b/devtools/__init__.py	Fri Oct 16 16:44:36 2015 +0200
@@ -564,6 +564,10 @@
                                '-o', options],
                               env=env)
     except OSError as err:
+        try:
+            os.rmdir(sockdir)
+        except OSError:
+            pass
         if err.errno == errno.ENOENT:
             raise OSError('"pg_ctl" could not be found. '
                           'You should add the postgresql bin folder to your PATH '
@@ -576,6 +580,10 @@
     datadir = join(os.path.dirname(pyfile), 'data',
                    'pgdb-%s' % os.path.splitext(os.path.basename(pyfile))[0])
     subprocess.call(['pg_ctl', 'stop', '-D', datadir, '-m', 'fast'])
+    try:
+        os.rmdir(DEFAULT_PSQL_SOURCES['system']['db-host'])
+    except OSError:
+        pass
 
 
 class PostgresTestDataBaseHandler(TestDataBaseHandler):