@@ -84,16 +84,6 @@ class InitNodeException(Exception):
8484 pass
8585
8686
87- class PgControlDataException (Exception ):
88- def __init__ (self , error_text , cmd ):
89- self .error_text = error_text
90- self .cmd = cmd
91-
92- def __str__ (self ):
93- self .error_text = repr (self .error_text )
94- return '\n ERROR: {0}\n CMD: {1}' .format (self .error_text , self .cmd )
95-
96-
9787class TestgresLogger (threading .Thread ):
9888 """
9989 Helper class to implement reading from postgresql.log
@@ -434,14 +424,10 @@ def get_control_data(self):
434424 Return contents of pg_control file
435425 """
436426
427+ _params = ["-D" , self .data_dir ]
428+ lines = _execute_utility ("pg_controldata" , _params , self .utils_logname )
429+
437430 out_data = {}
438- pg_controldata = get_bin_path ("pg_controldata" )
439- try :
440- lines = subprocess .check_output (
441- [pg_controldata ] + ["-D" , self .data_dir ],
442- stderr = subprocess .STDOUT ).decode ("utf-8" ).splitlines ()
443- except subprocess .CalledProcessError as e :
444- raise PgControlDataException (e .output , e .cmd )
445431
446432 for line in lines :
447433 key , value = line .partition (':' )[::2 ]
@@ -751,23 +737,23 @@ def _execute_utility(util, args, logfile):
751737
752738 # get result of pg_ctl
753739 out , _ = process .communicate ()
754-
755- # decode logs
756- log_text = out .decode ('utf-8' )
740+ out = out .decode ('utf-8' )
757741
758742 # write new log entry
759743 file_out .write ('' .join (map (lambda x : str (x ) + ' ' , [util ] + args )))
760744 file_out .write ('\n ' )
761- file_out .write (log_text )
745+ file_out .write (out )
762746
763747 if process .returncode :
764748 error_text = (
765749 "{} failed\n "
766750 "log:\n ----\n {}\n "
767- ).format (util , out . decode ( 'utf-8' ) )
751+ ).format (util , out )
768752
769753 raise ExecUtilException (error_text , process .returncode )
770754
755+ return out
756+
771757
772758def get_bin_path (filename ):
773759 """
0 commit comments