Skip to content

Commit 0dbf432

Browse files
committed
Migrate to QGIS 3
- Migrate QLR handling from QgsMapLayer.fromLayerDefinition to QgsLayerDefinition.loadLayerDefinitionLayers - Upgrade docker image to use qgis/qgis:release-3_14
1 parent 1708e71 commit 0dbf432

File tree

20 files changed

+291
-85
lines changed

20 files changed

+291
-85
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ sudo: required
33
language: python
44

55
python:
6-
- "2.7"
6+
- "3.6"
77

88
env:
99
global:
@@ -23,9 +23,6 @@ env:
2323
HEADLESS_COMMAND=dev
2424
SUBSEQUENT_RUN_TESTING=True
2525

26-
virtualenv:
27-
system_site_packages: true
28-
2926
services:
3027
- docker
3128

deployment/ansible/development/group_vars/all.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interpreters:
1616
inasafe:
1717
repo: https://github.com/inasafe/inasafe.git
1818
remote: upstream
19-
version: inasafe_4
19+
version: maintenance-fix
2020
depth: 1
2121

2222
inasafe_headless_worker:

deployment/docker-headless/Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#--------- Generic stuff all our Dockerfiles should start with so we get caching ------------
2-
FROM kartoza/qgis-desktop:2.18
2+
FROM qgis/qgis:release-3_14
33

44
RUN apt-get -y update; apt-get -y --force-yes install pwgen git inotify-tools
55

@@ -9,7 +9,10 @@ RUN apt-get -y update; apt-get -y --force-yes install pwgen git inotify-tools
99
RUN apt-get update -y; apt-get install -y --force-yes openssh-server sudo
1010
RUN mkdir /var/run/sshd
1111
RUN echo 'root:docker' | chpasswd
12-
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
12+
# Comment out PermitRootLogin setting, whatever it is
13+
RUN sed -i 's/^PermitRootLogin */#PermitRootLogin /' /etc/ssh/sshd_config
14+
# Write out PermitRootLogin setting at the end
15+
RUN echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
1316

1417
# SSH login fix. Otherwise user is kicked off after login
1518
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
@@ -21,8 +24,7 @@ RUN echo "export VISIBLE=now" >> /etc/profile
2124

2225
#-------------Application Specific Stuff ----------------------------------------------------
2326
# Install git, xvfb
24-
RUN apt-get -y update; apt-get -y --force-yes install git xvfb python-setuptools python-dev libssl-dev libffi-dev python-scipy
25-
RUN easy_install pip==9.0.1
27+
RUN apt-get -y update; apt-get -y --force-yes install git xvfb python3-setuptools python3-dev libssl-dev libffi-dev python3-scipy
2628
# Copy ubuntu fonts
2729
RUN apt-get -y update; apt-get -y --force-yes install wget unzip
2830
ADD ubuntu-font-family-0.83.zip /ubuntu-font-family-0.83.zip
@@ -31,8 +33,9 @@ RUN mv ubuntu-font-family-0.83 /usr/share/fonts/truetype/ubuntu-font-family
3133
RUN fc-cache -f -v
3234

3335
# This image instance uses dist-packages directory
34-
ADD sitecustomize.py /usr/local/lib/python2.7/dist-packages/sitecustomize.py
36+
ADD sitecustomize.py /usr/lib/python3/dist-packages/sitecustomize.py
3537
ADD REQUIREMENTS.txt /REQUIREMENTS.txt
38+
RUN ln -s /usr/bin/pip3 /usr/bin/pip
3639
RUN pip install -r REQUIREMENTS.txt
3740

3841
ADD docker-entrypoint.sh /docker-entrypoint.sh

deployment/docker-headless/docker-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Wait run xvfb
44
while [ -z "$(pidof /usr/bin/Xvfb)" ]; do
5-
start-stop-daemon --start -b -x /usr/bin/Xvfb ${DISPLAY}
5+
start-stop-daemon --start -b -x /usr/bin/Xvfb ${DISPLAY} -- -screen 0 1024x768x24 -ac +extension GLX +render -noreset -nolisten tcp
66
sleep 5
77
done
88

deployment/production/docker/headless/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#--------- Generic stuff all our Dockerfiles should start with so we get caching ------------
2-
FROM kartoza/qgis-desktop:2.18
2+
FROM qgis/qgis:release-3_14
33

44
RUN apt-get -y update; apt-get -y --force-yes install pwgen git inotify-tools
55

66
#-------------Application Specific Stuff ----------------------------------------------------
77
# Install git, xvfb
8-
RUN apt-get -y update; apt-get -y --force-yes install git xvfb python-setuptools python-dev libssl-dev libffi-dev python-scipy
9-
RUN easy_install pip==9.0.1
8+
RUN apt-get -y update; apt-get -y --force-yes install git xvfb python3-setuptools python3-dev libssl-dev libffi-dev python3-scipy
109
# Copy ubuntu fonts
1110
RUN apt-get -y update; apt-get -y --force-yes install wget unzip
1211
ADD ubuntu-font-family-0.83.zip /ubuntu-font-family-0.83.zip
@@ -15,6 +14,7 @@ RUN mv ubuntu-font-family-0.83 /usr/share/fonts/truetype/ubuntu-font-family
1514
RUN fc-cache -f -v
1615

1716
ADD REQUIREMENTS.txt /REQUIREMENTS.txt
17+
RUN ln -s /usr/bin/pip3 /usr/bin/pip
1818
RUN pip install -r REQUIREMENTS.txt
1919

2020
ADD docker-entrypoint.sh /docker-entrypoint.sh
@@ -23,7 +23,7 @@ RUN chmod +x /docker-entrypoint.sh
2323
# Install InaSAFE Core
2424
RUN mkdir -p /usr/share/qgis/python/plugins
2525
WORKDIR /usr/share/qgis/python/plugins
26-
ARG INASAFE_CORE_TAG=version-4_4_0
26+
ARG INASAFE_CORE_TAG=develop
2727
RUN git clone --branch ${INASAFE_CORE_TAG} --depth 1 --recursive https://github.com/inasafe/inasafe.git inasafe
2828

2929
# Install InaSAFE Headless

deployment/production/docker/headless/docker-entrypoint.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
# Wait run xvfb
44
while [ -z "$(pidof /usr/bin/Xvfb)" ]; do
5-
start-stop-daemon --start -b -x /usr/bin/Xvfb ${DISPLAY}
5+
start-stop-daemon --start -b -x /usr/bin/Xvfb ${DISPLAY} -- -screen 0 1024x768x24 -ac +extension GLX +render -noreset -nolisten tcp
66
sleep 5
77
done
88

99
cp -n /home/app/headless/celeryconfig_sample.py /home/app/headless/celeryconfig.py
10+
echo "Config file copied"
1011

1112
if [ $# -eq 2 ] && [ $1 = "prod" ] && [ $2 = "inasafe-headless-worker" ]; then
1213
/usr/local/bin/celery -A headless.celery_app worker -l info -Q inasafe-headless -n inasafe-headless.%h

src/headless/REQUIREMENTS.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
requests>=2.6.2
22
tzlocal==1.2
3-
celery==4.1.0
4-
nosexcover
3+
hammock==0.2.4
54
nose2==0.6.5
65
coverage==4.4.2
6+
threadpool==1.3.2
7+
pyinotify==0.9.6
8+
celery==4.1.1
79
raven==5.29.0
810
mock==2.0.0
11+
nose==1.3.7

src/headless/celery_app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# coding=utf-8
22
import importlib
3+
from importlib import reload
34
import json
45
import os
56

src/headless/tasks/inasafe_analysis.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
from copy import deepcopy
77
from datetime import datetime
8-
from PyQt4.QtCore import QUrl
8+
from qgis.PyQt.QtCore import QUrl
99

1010
from qgis.core import (
11-
QgsCoordinateReferenceSystem, QgsMapLayerRegistry, QgsProject)
11+
QgsCoordinateReferenceSystem, QgsProject)
1212

1313
from safe.definitions.constants import (
1414
PREPARE_SUCCESS, ANALYSIS_SUCCESS, MULTI_EXPOSURE_ANALYSIS_FLAG)
@@ -118,7 +118,7 @@ def inasafe_analysis(
118118
"""
119119
# Clean up layer registry before using
120120
# In case previous task exited prematurely before cleanup
121-
layer_registry = QgsMapLayerRegistry.instance()
121+
layer_registry = QgsProject.instance()
122122
layer_registry.removeAllMapLayers()
123123

124124
impact_function = ImpactFunction()
@@ -213,7 +213,7 @@ def inasafe_multi_exposure_analysis(
213213
"""
214214
# Clean up layer registry before using
215215
# In case previous task exited prematurely before cleanup
216-
layer_registry = QgsMapLayerRegistry.instance()
216+
layer_registry = QgsProject.instance()
217217
layer_registry.removeAllMapLayers()
218218

219219
multi_exposure_if = MultiExposureImpactFunction()
@@ -324,7 +324,7 @@ def generate_report(
324324
"""
325325
# Clean up layer registry before using
326326
# In case previous task exited prematurely before cleanup
327-
layer_registry = QgsMapLayerRegistry.instance()
327+
layer_registry = QgsProject.instance()
328328
layer_registry.removeAllMapLayers()
329329

330330
output_metadata = read_iso19115_metadata(impact_layer_uri)
@@ -344,14 +344,14 @@ def generate_report(
344344
root = QgsProject.instance().layerTreeRoot()
345345

346346
group_analysis = root.insertGroup(0, impact_function.name)
347-
group_analysis.setVisible(True)
347+
group_analysis.setItemVisibilityChecked(True)
348348
group_analysis.setCustomProperty(
349349
MULTI_EXPOSURE_ANALYSIS_FLAG, True)
350350

351351
for layer in impact_function.outputs:
352-
QgsMapLayerRegistry.instance().addMapLayer(layer, False)
352+
QgsProject.instance().addMapLayer(layer, False)
353353
layer_node = group_analysis.addLayer(layer)
354-
layer_node.setVisible(False)
354+
layer_node.setItemVisibilityChecked(False)
355355

356356
# set layer title if any
357357
try:
@@ -362,7 +362,7 @@ def generate_report(
362362

363363
for analysis in impact_function.impact_functions:
364364
detailed_group = group_analysis.insertGroup(0, analysis.name)
365-
detailed_group.setVisible(True)
365+
detailed_group.setItemVisibilityChecked(True)
366366
add_impact_layers_to_canvas(analysis, group=detailed_group)
367367
else:
368368
impact_function = (

src/headless/tasks/inasafe_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding=utf-8
22
"""Task for InaSAFE Headless."""
3-
3+
from importlib import reload
44
from headless.celery_app import app, start_inasafe
55
from headless.tasks import inasafe_analysis
66
from headless.utils import get_headless_logger

0 commit comments

Comments
 (0)