Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd09bdb

Browse files
committed
allow using PG_BIN env instead of PG_CONFIG
1 parent6546fc8 commitfd09bdb

File tree

1 file changed

+34
-12
lines changed

1 file changed

+34
-12
lines changed

‎testgres/testgres.py

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def default_conf(self, allow_streaming=True, fsync=False, log_statement='all'):
539539
self.port))
540540

541541
ifallow_streaming:
542-
cur_ver=LooseVersion(get_pg_config()["VERSION_NUM"])
542+
cur_ver=LooseVersion(get_pg_version())
543543
min_ver=LooseVersion('9.6')
544544

545545
# select a proper wal_level for PostgreSQL
@@ -609,7 +609,10 @@ def get_control_data(self):
609609
Return contents of pg_control file.
610610
"""
611611

612-
ifget_pg_config()["VERSION_NUM"]<'9.5.0':
612+
cur_ver=LooseVersion(get_pg_version())
613+
min_ver=LooseVersion('9.5')
614+
615+
ifcur_ver<min_ver:
613616
_params= [self.data_dir]
614617
else:
615618
_params= ["-D",self.data_dir]
@@ -1002,7 +1005,7 @@ def catchup(self):
10021005

10031006
master=self.master
10041007

1005-
cur_ver=LooseVersion(get_pg_config()["VERSION_NUM"])
1008+
cur_ver=LooseVersion(get_pg_version())
10061009
min_ver=LooseVersion('10')
10071010

10081011
ifcur_ver>=min_ver:
@@ -1166,9 +1169,14 @@ def default_username():
11661169

11671170
defget_bin_path(filename):
11681171
"""
1169-
Return full path to an executable usingget_pg_config().
1172+
Return full path to an executable usingPG_BIN or PG_CONFIG.
11701173
"""
11711174

1175+
pg_bin_path=os.environ.get("PG_BIN")
1176+
1177+
ifpg_bin_path:
1178+
returnos.path.join(pg_bin_path,filename)
1179+
11721180
pg_config=get_pg_config()
11731181

11741182
ifpg_configand"BINDIR"inpg_config:
@@ -1177,6 +1185,28 @@ def get_bin_path(filename):
11771185
returnfilename
11781186

11791187

1188+
defget_pg_version():
1189+
"""
1190+
Return PostgreSQL version using PG_BIN or PG_CONFIG.
1191+
"""
1192+
1193+
pg_bin_path=os.environ.get("PG_BIN")
1194+
1195+
ifpg_bin_path:
1196+
_params= ['--version']
1197+
raw_ver=_execute_utility('psql',_params,os.devnull)
1198+
else:
1199+
raw_ver=get_pg_config()["VERSION"]
1200+
1201+
# Cook version of PostgreSQL
1202+
version=raw_ver.strip().split(" ")[-1] \
1203+
.partition('devel')[0] \
1204+
.partition('beta')[0] \
1205+
.partition('rc')[0]
1206+
1207+
returnversion
1208+
1209+
11801210
defreserve_port():
11811211
"""
11821212
Generate a new port and add it to 'bound_ports'.
@@ -1215,14 +1245,6 @@ def get_pg_config():
12151245
key,value=line.split("=",1)
12161246
data[key.strip()]=value.strip()
12171247

1218-
# Fetch version of PostgreSQL and save it as VERSION_NUM
1219-
version=data["VERSION"]
1220-
version=version.split(" ")[-1] \
1221-
.partition('devel')[0] \
1222-
.partition('beta')[0] \
1223-
.partition('rc')[0]
1224-
data["VERSION_NUM"]=version
1225-
12261248
ifTestgresConfig.cache_pg_config:
12271249
pg_config_data.clear()
12281250
pg_config_data.update(data)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp