Fixes urllib2 issues
Adds s3filestore requirements in Dockerfile
This commit is contained in:
parent
ee215d0db5
commit
9829cafc86
|
@ -82,7 +82,8 @@ RUN curl -o ${SRC_DIR}/get-pip.py https://bootstrap.pypa.io/get-pip.py && \
|
||||||
# Fetch and build the default CKAN extensions
|
# Fetch and build the default CKAN extensions
|
||||||
RUN pip wheel --wheel-dir=/wheels git+${ENVVARS_GIT_URL}@${ENVVARS_GIT_BRANCH}#egg=ckanext-envvars
|
RUN pip wheel --wheel-dir=/wheels git+${ENVVARS_GIT_URL}@${ENVVARS_GIT_BRANCH}#egg=ckanext-envvars
|
||||||
RUN pip wheel --wheel-dir=/wheels git+${S3FILESTORE_GIT_URL}@${S3FILESTORE_GIT_BRANCH}#egg=ckanext-s3filestore
|
RUN pip wheel --wheel-dir=/wheels git+${S3FILESTORE_GIT_URL}@${S3FILESTORE_GIT_BRANCH}#egg=ckanext-s3filestore
|
||||||
|
RUN pip wheel --wheel-dir=/wheels -r https://raw.githubusercontent.com/okfn/ckanext-s3filestore/${S3FILESTORE_GIT_BRANCH}/requirements.txt
|
||||||
|
RUN curl -o /wheels/s3filestore.txt https://raw.githubusercontent.com/okfn/ckanext-s3filestore/${S3FILESTORE_GIT_BRANCH}/requirements.txt
|
||||||
|
|
||||||
############
|
############
|
||||||
### MAIN ###
|
### MAIN ###
|
||||||
|
@ -138,6 +139,7 @@ RUN pip install -e /srv/app/src/ckan && \
|
||||||
pip install --no-index --find-links=/srv/app/wheels -r requirements.txt && \
|
pip install --no-index --find-links=/srv/app/wheels -r requirements.txt && \
|
||||||
# Install default CKAN extensions
|
# Install default CKAN extensions
|
||||||
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-envvars ckanext-s3filestore && \
|
pip install --no-index --find-links=/srv/app/ext_wheels ckanext-envvars ckanext-s3filestore && \
|
||||||
|
pip install --no-index --find-links=/srv/app/ext_wheels -r /srv/app/ext_wheels/s3filestore.txt && \
|
||||||
# Create and update CKAN config
|
# Create and update CKAN config
|
||||||
# Set timezone
|
# Set timezone
|
||||||
echo "UTC" > /etc/timezone && \
|
echo "UTC" > /etc/timezone && \
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import psycopg2
|
import psycopg2
|
||||||
import urllib.request, urllib.error, urllib.parse
|
import urllib2
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
@ -48,8 +48,8 @@ def check_solr_connection(retry=None):
|
||||||
search_url = '{url}/select/?q=*&wt=json'.format(url=url)
|
search_url = '{url}/select/?q=*&wt=json'.format(url=url)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
connection = urllib.request.urlopen(search_url)
|
connection = urllib2.urlopen(search_url)
|
||||||
except urllib.error.URLError as e:
|
except urllib2.URLError as e:
|
||||||
print((str(e)))
|
print((str(e)))
|
||||||
print('[prerun] Unable to connect to solr...try again in a while.')
|
print('[prerun] Unable to connect to solr...try again in a while.')
|
||||||
import time
|
import time
|
||||||
|
@ -58,15 +58,16 @@ def check_solr_connection(retry=None):
|
||||||
else:
|
else:
|
||||||
import re
|
import re
|
||||||
conn_info = connection.read()
|
conn_info = connection.read()
|
||||||
|
conn_info = re.sub(r'"zkConnected":true', '"zkConnected":True', conn_info)
|
||||||
eval(conn_info)
|
eval(conn_info)
|
||||||
|
|
||||||
def init_db():
|
def init_db():
|
||||||
|
|
||||||
print('[prerun] Start init_db...')
|
print('[prerun] Start init_db...')
|
||||||
|
|
||||||
db_command = ['ckan', '-c', ckan_ini, 'db', 'init']
|
db_command = ['paster', '--plugin=ckan', 'db', 'init', '-c', ckan_ini]
|
||||||
|
|
||||||
print('[prerun] Initializing or upgrading db - start using ckan db init')
|
print('[prerun] Initializing or upgrading db - start using paster db init')
|
||||||
try:
|
try:
|
||||||
# run init scripts
|
# run init scripts
|
||||||
subprocess.check_output(db_command, stderr=subprocess.STDOUT)
|
subprocess.check_output(db_command, stderr=subprocess.STDOUT)
|
||||||
|
@ -92,8 +93,8 @@ def init_datastore():
|
||||||
print('[prerun] Skipping datastore initialization')
|
print('[prerun] Skipping datastore initialization')
|
||||||
return
|
return
|
||||||
|
|
||||||
datastore_perms_command = ['ckan', '-c', ckan_ini, 'datastore',
|
datastore_perms_command = ['paster', '--plugin=ckan', 'datastore',
|
||||||
'set-permissions']
|
'set-permissions', '-c', ckan_ini]
|
||||||
|
|
||||||
connection = psycopg2.connect(conn_str)
|
connection = psycopg2.connect(conn_str)
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
|
@ -144,7 +145,7 @@ def create_sysadmin():
|
||||||
if name and password and email:
|
if name and password and email:
|
||||||
|
|
||||||
# Check if user exists
|
# Check if user exists
|
||||||
command = ['ckan', '-c', ckan_ini, 'user', 'show', name]
|
command = ['paster', '--plugin=ckan', 'user', name, '-c', ckan_ini]
|
||||||
|
|
||||||
out = subprocess.check_output(command)
|
out = subprocess.check_output(command)
|
||||||
if 'User:None' not in re.sub(r'\s', '', out.decode('utf-8')):
|
if 'User:None' not in re.sub(r'\s', '', out.decode('utf-8')):
|
||||||
|
@ -152,17 +153,19 @@ def create_sysadmin():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create user
|
# Create user
|
||||||
command = ['ckan', '-c', ckan_ini, 'user', 'add',
|
command = ['paster', '--plugin=ckan', 'user', 'add',
|
||||||
name,
|
name,
|
||||||
'password=' + password,
|
'password=' + password,
|
||||||
'email=' + email]
|
'email=' + email,
|
||||||
|
'-c', ckan_ini]
|
||||||
|
|
||||||
subprocess.call(command)
|
subprocess.call(command)
|
||||||
print(('[prerun] Created user {0}'.format(name)))
|
print(('[prerun] Created user {0}'.format(name)))
|
||||||
|
|
||||||
# Make it sysadmin
|
# Make it sysadmin
|
||||||
command = ['ckan', '-c', ckan_ini, 'sysadmin', 'add',
|
command = ['paster', '--plugin=ckan', 'sysadmin', 'add',
|
||||||
name]
|
name,
|
||||||
|
'-c', ckan_ini]
|
||||||
|
|
||||||
subprocess.call(command)
|
subprocess.call(command)
|
||||||
print(('[prerun] Made user {0} a sysadmin'.format(name)))
|
print(('[prerun] Made user {0} a sysadmin'.format(name)))
|
||||||
|
|
Loading…
Reference in New Issue