89
89
from .utils import \
90
90
PgVer , \
91
91
eprint , \
92
- get_bin_path , \
92
+ get_bin_path2 , \
93
93
get_pg_version , \
94
- execute_utility , \
94
+ execute_utility2 , \
95
95
options_string , \
96
96
clean_on_error
97
97
@@ -301,7 +301,7 @@ def base_dir(self):
301
301
@property
302
302
def bin_dir (self ):
303
303
if not self ._bin_dir :
304
- self ._bin_dir = os .path .dirname (get_bin_path ( "pg_config" ))
304
+ self ._bin_dir = os .path .dirname (get_bin_path2 ( self . os_ops , "pg_config" ))
305
305
return self ._bin_dir
306
306
307
307
@property
@@ -684,7 +684,7 @@ def status(self):
684
684
"-D" , self .data_dir ,
685
685
"status"
686
686
] # yapf: disable
687
- status_code , out , error = execute_utility ( _params , self .utils_log_file , verbose = True )
687
+ status_code , out , error = execute_utility2 ( self . os_ops , _params , self .utils_log_file , verbose = True )
688
688
if error and 'does not exist' in error :
689
689
return NodeStatus .Uninitialized
690
690
elif 'no server running' in out :
@@ -710,7 +710,7 @@ def get_control_data(self):
710
710
_params += ["-D" ] if self ._pg_version >= PgVer ('9.5' ) else []
711
711
_params += [self .data_dir ]
712
712
713
- data = execute_utility ( _params , self .utils_log_file )
713
+ data = execute_utility2 ( self . os_ops , _params , self .utils_log_file )
714
714
715
715
out_dict = {}
716
716
@@ -793,7 +793,7 @@ def start(self, params=[], wait=True):
793
793
794
794
def LOCAL__start_node ():
795
795
# 'error' will be None on Windows
796
- _ , _ , error = execute_utility ( _params , self .utils_log_file , verbose = True )
796
+ _ , _ , error = execute_utility2 ( self . os_ops , _params , self .utils_log_file , verbose = True )
797
797
assert error is None or type (error ) == str # noqa: E721
798
798
if error and 'does not exist' in error :
799
799
raise Exception (error )
@@ -882,7 +882,7 @@ def stop(self, params=[], wait=True):
882
882
"stop"
883
883
] + params # yapf: disable
884
884
885
- execute_utility ( _params , self .utils_log_file )
885
+ execute_utility2 ( self . os_ops , _params , self .utils_log_file )
886
886
887
887
self ._maybe_stop_logger ()
888
888
self .is_started = False
@@ -924,7 +924,7 @@ def restart(self, params=[]):
924
924
] + params # yapf: disable
925
925
926
926
try :
927
- error_code , out , error = execute_utility ( _params , self .utils_log_file , verbose = True )
927
+ error_code , out , error = execute_utility2 ( self . os_ops , _params , self .utils_log_file , verbose = True )
928
928
if error and 'could not start server' in error :
929
929
raise ExecUtilException
930
930
except ExecUtilException as e :
@@ -953,7 +953,7 @@ def reload(self, params=[]):
953
953
"reload"
954
954
] + params # yapf: disable
955
955
956
- execute_utility ( _params , self .utils_log_file )
956
+ execute_utility2 ( self . os_ops , _params , self .utils_log_file )
957
957
958
958
return self
959
959
@@ -975,7 +975,7 @@ def promote(self, dbname=None, username=None):
975
975
"promote"
976
976
] # yapf: disable
977
977
978
- execute_utility ( _params , self .utils_log_file )
978
+ execute_utility2 ( self . os_ops , _params , self .utils_log_file )
979
979
980
980
# for versions below 10 `promote` is asynchronous so we need to wait
981
981
# until it actually becomes writable
@@ -1010,7 +1010,7 @@ def pg_ctl(self, params):
1010
1010
"-w" # wait
1011
1011
] + params # yapf: disable
1012
1012
1013
- return execute_utility ( _params , self .utils_log_file )
1013
+ return execute_utility2 ( self . os_ops , _params , self .utils_log_file )
1014
1014
1015
1015
def free_port (self ):
1016
1016
"""
@@ -1230,7 +1230,7 @@ def tmpfile():
1230
1230
"-F" , format .value
1231
1231
] # yapf: disable
1232
1232
1233
- execute_utility ( _params , self .utils_log_file )
1233
+ execute_utility2 ( self . os_ops , _params , self .utils_log_file )
1234
1234
1235
1235
return filename
1236
1236
@@ -1259,7 +1259,7 @@ def restore(self, filename, dbname=None, username=None):
1259
1259
1260
1260
# try pg_restore if dump is binary format, and psql if not
1261
1261
try :
1262
- execute_utility ( _params , self .utils_log_name )
1262
+ execute_utility2 ( self . os_ops , _params , self .utils_log_name )
1263
1263
except ExecUtilException :
1264
1264
self .psql (filename = filename , dbname = dbname , username = username )
1265
1265
@@ -1612,7 +1612,7 @@ def pgbench_run(self, dbname=None, username=None, options=[], **kwargs):
1612
1612
# should be the last one
1613
1613
_params .append (dbname )
1614
1614
1615
- return execute_utility ( _params , self .utils_log_file )
1615
+ return execute_utility2 ( self . os_ops , _params , self .utils_log_file )
1616
1616
1617
1617
def connect (self ,
1618
1618
dbname = None ,
@@ -1809,7 +1809,7 @@ def _get_bin_path(self, filename):
1809
1809
if self .bin_dir :
1810
1810
bin_path = os .path .join (self .bin_dir , filename )
1811
1811
else :
1812
- bin_path = get_bin_path ( filename )
1812
+ bin_path = get_bin_path2 ( self . os_ops , filename )
1813
1813
return bin_path
1814
1814
1815
1815
def _escape_config_value (value ):
0 commit comments