def getPostgreSQLDatabases(password):
    try:
        dbList = []
        f = ""
        confFileExists = False
 
        # ---------------------------------------------------------------------
        # Create path variables
        # ---------------------------------------------------------------------
        confFileFolder = os.path.join(os.environ['APPDATA'], "postgresql")
        confFilePath = os.path.join(confFileFolder, "pgpass.conf")
        
	#Location where calling script is located
        scriptFileFolder = os.path.dirname(sys.argv[0])
	
	#supportFilesPath = os.path.join(scriptFileFolder, "SupportFiles")
        scriptFilePath =  os.path.join(scriptFileFolder, "RunPostgreSQLStatement.bat")
        outFile = os.path.join(scriptFileFolder, "DatabaseOutput.txt")

        # Delete file containing database names (outFile) if it already exists
        if os.path.exists(outFile):
            os.remove(outFile)
            
        # ---------------------------------------------------------------------
        # Create postgreSQL password configuration file
        # NOTE: must be located in %APPDATA%\postgresql folder and must
        # be called pgpass.conf
        # ---------------------------------------------------------------------
        # The script file runs psql.exe which will prompt for a password
        # unless the pgpass.config file contains the connection information.
        # The file should have the following format:
        # hostname:port:database:username:password
        confString = "localhost:5432:postgres:postgres:" + password
        
        # Create postgres folder if it does not exist.
        if not os.path.exists(confFileFolder):
            os.makedirs(confFileFolder)
        
        # Check if config file already exists
        if os.path.exists(confFilePath):
            confFileExists = True
            os.rename(confFilePath, confFilePath + ".bak")
        
        # File doesn't exist so create it using the w mode
        conf_f = open(confFilePath, "w")
        
        # Write to config file
        conf_f.write(confString + "\n")
        conf_f.close()
        
        # ---------------------------------------------------------------------
        # Create batch file with psql command
        # ---------------------------------------------------------------------
        print "\t\t-Creating batch file: " + scriptFilePath + "..."
	psqlExePath = findFilePath(rootPostgreSQLPath, "psql.exe")
    
        strToWrite = '"' + psqlExePath + '" -U postgres -p 5432 -d postgres ' + \
                '-h localhost -f ' + scriptFileFolder + os.sep + \
		'ListPostgresDatabases.sql > ' + outFile
	
        # Create file/overwrite existing
        batFile_f = open(scriptFilePath, "w")
        batFile_f.write(strToWrite + "\n")
        batFile_f.close()
        
        # ---------------------------------------------------------------------
        # Run batch file that connects to postgreSQL postgres database
        # and queries pg_database table.
        # ---------------------------------------------------------------------
        print "\t\t-Executing batch file (" + scriptFilePath + ")"
        print "\t\tto determine existing PostgreSQL databases..."
            
        #Run batch file that executes sql statement
        subprocess.call(scriptFilePath)
        
        # Read output file and add database names to list
        if os.path.exists(outFile):
            f = open(outFile, "r")
            for line in f:
                # remove leading/trailing spaces
                line = line.strip()
                if line == "datname" or line.find("--") <> -1 or \
                    line.find(" rows") <> -1:
                    # skip line
                    continue
                if 0 > len(line):
                    #added this check because it extra blank line is
                    # in file
                    dbList.append(line)
            
    except:
        # Get the traceback object
        tb = sys.exc_info()[2]
        tbinfo = traceback.format_tb(tb)[0]
     
        # Concatenate information together concerning the error into a message string
        pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
        
        # Print Python error messages for use in Python / Python Window
        print
        print "***** ERROR ENCOUNTERED *****"
        print pymsg + "\n"

    finally:
        if f:
            f.close()
        if conf_f:
            conf_f.close()
            
        # Delete the config file we created
        os.remove(confFilePath)
        
        # Rename backup config if existed
        if confFileExists:
            os.rename(confFilePath + ".bak", confFilePath)

        return dbList
dataset/ETHPy150Open Esri/ops-server-config/Install/ArcGISServer/SupportFiles/PreConfigurationChecks.py/getPostgreSQLDatabases/swapped operands of `>`