~lazr-developers/postgresfixture/trunk

« back to all changes in this revision

Viewing changes to postgresfixture/cluster.py

  • Committer: Gavin Panella
  • Date: 2014-01-17 18:05:11 UTC
  • mfrom: (8.1.1 trusty-compatibility)
  • Revision ID: gavin.panella@canonical.com-20140117180511-5hsc1c5evr7ypt1o
[r=allenap] Accommodate differences between PostgreSQL's pg_ctl in version 9.1 and >= 9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
141
141
            try:
142
142
                self.execute("pg_ctl", "status", stdout=null)
143
143
            except CalledProcessError as error:
144
 
                if error.returncode == 1:
145
 
                    return False
 
144
                # pg_ctl in PostgreSQL 9.1 returns 1 when the server is
 
145
                # not running, whereas it returns 3 in PostgreSQL 9.2
 
146
                # and later. This checks for specific codes to avoid
 
147
                # masking errors from insufficient permissions or
 
148
                # missing executables, for example.
 
149
                if LooseVersion(self.version) >= LooseVersion("9.2"):
 
150
                    if error.returncode == 3:
 
151
                        return False
146
152
                else:
147
 
                    raise
 
153
                    if error.returncode == 1:
 
154
                        return False
 
155
                # Some other error: moan about it.
 
156
                raise
148
157
            else:
149
158
                return True
150
159