|
29 | 29 | import tempfile
|
30 | 30 | import shutil
|
31 | 31 | import time
|
| 32 | +import six |
32 | 33 |
|
33 | 34 | # Try to use psycopg2 by default. If psycopg2 isn"t available then use
|
34 | 35 | # pg8000 which is slower but much more portable because uses only
|
@@ -120,7 +121,7 @@ def close(self):
|
120 | 121 | self.connection.close()
|
121 | 122 |
|
122 | 123 |
|
123 |
| -class PostgresNode: |
| 124 | +class PostgresNode(object): |
124 | 125 | def __init__(self, name, port):
|
125 | 126 | self.name = name
|
126 | 127 | self.host = '127.0.0.1'
|
@@ -258,7 +259,7 @@ def pg_ctl(self, command, params):
|
258 | 259 | pg_ctl = self.get_bin_path("pg_ctl")
|
259 | 260 |
|
260 | 261 | arguments = [pg_ctl]
|
261 |
| - for key, value in params.iteritems(): |
| 262 | + for key, value in six.iteritems(params): |
262 | 263 | arguments.append(key)
|
263 | 264 | if value:
|
264 | 265 | arguments.append(value)
|
@@ -363,9 +364,8 @@ def poll_query_until(self, dbname, query):
|
363 | 364 |
|
364 | 365 | while attemps < max_attemps:
|
365 | 366 | ret = self.safe_psql(dbname, query)
|
366 |
| - |
367 | 367 | # TODO: fix psql so that it returns result without newline
|
368 |
| - if ret == "t\n": |
| 368 | + if ret == six.b("t\n"): |
369 | 369 | return
|
370 | 370 |
|
371 | 371 | time.sleep(1)
|
@@ -410,10 +410,10 @@ def get_config():
|
410 | 410 | pg_config_cmd = os.environ.get("PG_CONFIG") \
|
411 | 411 | if "PG_CONFIG" in os.environ else "pg_config"
|
412 | 412 |
|
413 |
| - out = subprocess.check_output([pg_config_cmd]) |
414 |
| - for line in out.split("\n"): |
415 |
| - if line: |
416 |
| - key, value = unicode(line).split("=", 1) |
| 413 | + out = six.StringIO(subprocess.check_output([pg_config_cmd], universal_newlines=True)) |
| 414 | + for line in out: |
| 415 | + if line and "=" in line: |
| 416 | + key, value = line.split("=", 1) |
417 | 417 | pg_config_data[key.strip()] = value.strip()
|
418 | 418 |
|
419 | 419 | # Numeric version format
|
|
0 commit comments