qcfractal/postgres_harness.py
def initialize_postgres(self) -> None:
        """Initializes and starts the current postgres instance.
        """

        self._check_psql()

        self.logger("Initializing the Postgresql database:")

        # Initialize the database
        init_status = self._run([shutil.which("initdb"), "-D", self.config.database_path])
        if "Success." not in init_status["stdout"]:
            raise ValueError(f"Could not initialize the PostgreSQL server. Error below:\n\n{init_status['stderr']}")

        # Change any configurations
        psql_conf_file = self.config.database_path / "postgresql.conf"
        psql_conf = psql_conf_file.read_text()
        if self.config.database.port != 5432:
            assert "#port = 5432" in psql_conf
            psql_conf = psql_conf.replace("#port = 5432", f"port = {self.config.database.port}")

            psql_conf_file.write_text(psql_conf)

        # Start the database
        self.start()

        # Create the user and database
        self.logger(f"Building user information.")
        self._run([shutil.which("createdb"), "-p", str(self.config.database.port)])

        success = self.create_database(self.config.database.database_name)

        if success is False:
            self.shutdown()
            raise ValueError("Database created successfully, but could not connect. Shutting down postgres.")

        self.logger("\nDatabase server successfully started!")
Initializes and starts the current postgres instance.
        
Initializes and starts the current postgres instance.
Initializes and starts the current postgres instance .
def initialize_postgres(self) -> None:
        self._check_psql()
        self.logger("Initializing the Postgresql database:")
        init_status = self._run([shutil.which("initdb"), "-D", self.config.database_path])
        if "Success." not in init_status["stdout"]:
            raise ValueError(f"Could not initialize the PostgreSQL server. Error below:\n\n{init_status['stderr']}")
        psql_conf_file = self.config.database_path / "postgresql.conf"
        psql_conf = psql_conf_file.read_text()
        if self.config.database.port != 5432:
            assert "#port = 5432" in psql_conf
            psql_conf = psql_conf.replace("#port = 5432", f"port = {self.config.database.port}")
            psql_conf_file.write_text(psql_conf)
        self.start()
        self.logger(f"Building user information.")
        self._run([shutil.which("createdb"), "-p", str(self.config.database.port)])
        success = self.create_database(self.config.database.database_name)
        if success is False:
            self.shutdown()
            raise ValueError("Database created successfully, but could not connect. Shutting down postgres.")
        self.logger("\nDatabase server successfully started!")
def initialize_postgres ( self ) -> None : self . _check_psql ( ) self . logger ( "Initializing the Postgresql database:" ) init_status = self . _run ( [ shutil . which ( "initdb" ) , "-D" , self . config . database_path ] ) if "Success." not in init_status [ "stdout" ] : raise ValueError ( f"Could not initialize the PostgreSQL server. Error below:\n\n{init_status['stderr']}" ) psql_conf_file = self . config . database_path / "postgresql.conf" psql_conf = psql_conf_file . read_text ( ) if self . config . database . port != 5432 : assert "#port = 5432" in psql_conf psql_conf = psql_conf . replace ( "#port = 5432" , f"port = {self.config.database.port}" ) psql_conf_file . write_text ( psql_conf ) self . start ( ) self . logger ( f"Building user information." ) self . _run ( [ shutil . which ( "createdb" ) , "-p" , str ( self . config . database . port ) ] ) success = self . create_database ( self . config . database . database_name ) if success is False : self . shutdown ( ) raise ValueError ( "Database created successfully, but could not connect. Shutting down postgres." ) self . logger ( "\nDatabase server successfully started!" )
Initializes and starts the current postgres instance.
Initializes and starts the current postgres instance .
"""Initializes and starts the current postgres instance.
        """ # Initialize the database # Change any configurations # Start the database # Create the user and database
self