update prerun.py

This commit is contained in:
Brett 2022-07-14 15:22:02 +02:00
parent 5dc55f8693
commit cbc9528836
2 changed files with 10 additions and 2 deletions

View File

@ -29,6 +29,7 @@ Go through all the new changes in the current repo and use those for the new rep
- Check out Florian's repo https://github.com/dbca-wa/ckan/tree/dbca2022
- Documentation to be re-done from scratch...anything that could be useful can be mentioned here eg: local storage for ckan.ini
- Had to update the prerun.py script as it was failing on check_solr_connection
ToDo (workarounds to fix)

View File

@ -11,6 +11,7 @@ except ImportError:
import time
import re
import json
ckan_ini = os.environ.get("CKAN_INI", "/srv/app/ckan.ini")
@ -72,7 +73,7 @@ def check_solr_connection(retry=None):
sys.exit(1)
url = os.environ.get("CKAN_SOLR_URL", "")
search_url = "{url}/select/?q=*&wt=json".format(url=url)
search_url = '{url}/schema/name?wt=json'.format(url=url)
try:
connection = urlopen(search_url)
@ -82,7 +83,13 @@ def check_solr_connection(retry=None):
time.sleep(10)
check_solr_connection(retry=retry - 1)
else:
eval(connection.read())
import re
conn_info = connection.read()
schema_name = json.loads(conn_info)
if 'ckan' in schema_name['name']:
print('[prerun] Succesfully connected to solr and CKAN schema loaded')
else:
print('[prerun] Succesfully connected to solr, but CKAN schema not found')
def init_db():