Skip to content

Commit f99ef5b

Browse files
committed
Add Travis.ci and docker
1 parent 6a7a8b2 commit f99ef5b

26 files changed

+184
-101
lines changed

.DS_Store

16 KB
Binary file not shown.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ __pycache__/
55
*.py[cod]
66
*$py.class
77

8+
# Test files
9+
.pytest_cache/*
10+
811
# C extensions
912
*.so
1013

@@ -115,3 +118,4 @@ cfg/dev-mapswipe_serviceAccountKey.json
115118

116119

117120

121+
.DS_Store

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: python
2+
sudo: required
3+
python:
4+
- "3.6"
5+
# command to install dependencies
6+
before_install:
7+
# install gdal
8+
- sudo bash install_gdal.sh
9+
install:
10+
- export CPLUS_INCLUDE_PATH=/usr/include/gdal
11+
- export C_INCLUDE_PATH=/usr/include/gdal
12+
- export PYTHONPATH=$PYTHONPATH:$(pwd)
13+
- pip install -r requirements.txt
14+
- python setup.py install
15+
# command to run tests
16+
script:
17+
- pytest

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests:
2+
# TODO - Include in install.
3+
pip install -r requirements.txt
4+
python setup.py install
5+
pytest
6+
7+
# [Dummy dependency to force a make command to always run.]
8+
FORCE:

cfg/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Default init.py."""

cfg/auth.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
############################################
55

66
import pyrebase
7-
import pymysql #handle mysql
7+
import pymysql # handle mysql
88
import json
99
import sys
1010

@@ -37,6 +37,7 @@ def firebase_admin_auth():
3737
firebase = pyrebase.initialize_app(config)
3838
return firebase
3939

40+
4041
def dev_firebase_admin_auth():
4142
try:
4243
with open('../cfg/config.cfg') as json_data_file:
@@ -105,7 +106,7 @@ def __init__(self):
105106
user = data['mysql']['username']
106107
password = data['mysql']['password']
107108
host = data['mysql']['host']
108-
#print('use configuration for mysql as provided by config.json')
109+
# print('use configuration for mysql as provided by config.json')
109110
except:
110111
print('we could not load mysql info the config file')
111112
sys.exit()
@@ -134,7 +135,7 @@ def retr_query(self, query, data):
134135
return content
135136

136137
def __del__(self):
137-
#self._db_cur.close()
138+
# self._db_cur.close()
138139
self._db_connection.close()
139140

140141

@@ -151,13 +152,12 @@ def __init__(self):
151152
user = data['dev_mysql']['username']
152153
password = data['dev_mysql']['password']
153154
host = data['dev_mysql']['host']
154-
#print('use configuration for mysql as provided by config.json')
155+
# print('use configuration for mysql as provided by config.json')
155156
except:
156157
# Default configuration
157158
print('we could not load mysql dev info from the config file')
158159
sys.exit()
159160

160-
161161
self._db_connection = pymysql.connect(
162162
database=dbname,
163163
user=user,
@@ -182,5 +182,5 @@ def retr_query(self, query, data):
182182
return content
183183

184184
def __del__(self):
185-
#self._db_cur.close()
185+
# self._db_cur.close()
186186
self._db_connection.close()

docker/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Simple Python Dockerfile to run tests.
2+
FROM python:3.6
3+
4+
5+
RUN apt-get update
6+
# Upgrade repo for GDAL
7+
# RUN apt-get install python-software-properties
8+
RUN apt-get -y install software-properties-common
9+
RUN add-apt-repository ppa:ubuntugis/ppa
10+
11+
# Install binary dependencies and GDAL
12+
COPY ./install_gdal.sh .
13+
RUN bash install_gdal.sh
14+
15+
16+
# Install requirements for the first time
17+
COPY ./requirements.txt .
18+
RUN pip install -r requirements.txt
19+
20+
RUN mkdir -p /home/mapswipe-workers
21+
WORKDIR /home/mapswipe-workers

docker/docker-compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "2"
2+
services:
3+
mapswipe-workers:
4+
build:
5+
context: ../.
6+
dockerfile: ./docker/Dockerfile
7+
volumes:
8+
# Copy complete folder.
9+
- .././:/home/mapswipe-workers/:rw
10+
# FIXME - Add working test command.
11+
# command: "cd /home/mapswipe-workers/; make tests"

export_module/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Default init.py."""

export_module/run_export.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
#!/bin/python3
22
# -*- coding: UTF-8 -*-
33
# Author: M. Reinmuth, B. Herfort
4-
########################################################################################################################
4+
####################################################################################################
55

66
import sys
7-
# add some files in different folders to sys.
8-
# these files can than be loaded directly
9-
sys.path.insert(0, '../cfg/')
10-
sys.path.insert(0, '../utils/')
117

128
import logging
139

14-
import error_handling
15-
16-
from export_project_results import export_project_results
17-
from export_projects import export_projects
18-
from export_users_and_stats import export_users_and_stats
19-
20-
from auth import firebase_admin_auth
21-
from send_slack_message import send_slack_message
10+
from export_module.export_project_results import export_project_results
11+
from export_module.export_projects import export_projects
12+
from export_module.export_users_and_stats import export_users_and_stats
13+
from cfg.auth import firebase_admin_auth
14+
from utils.send_slack_message import send_slack_message
2215

2316
import time
2417
import argparse
@@ -27,9 +20,10 @@
2720
# define arguments that can be passed by the user
2821
parser = argparse.ArgumentParser(description='Process some integers.')
2922
parser.add_argument('-l', '--loop', dest='loop', action='store_true',
30-
help='if loop is set, the import will be repeated several times. You can specify the behaviour using --sleep_time and/or --max_iterations.')
23+
help='if loop is set, the import will be repeated several times.'
24+
'You can specify the behaviour using --sleep_time / --max_iterations.')
3125
parser.add_argument('-s', '--sleep_time', required=False, default=None, type=int,
32-
help='the time in seconds for which the script will pause in beetween two imports')
26+
help='time in seconds for which the script will pause in beetween two imports.')
3327
parser.add_argument('-m', '--max_iterations', required=False, default=None, type=int,
3428
help='the maximum number of imports that should be performed')
3529

@@ -39,9 +33,10 @@
3933
parser.add_argument('-p', '--user_project_list', nargs='+', required=None, default=None, type=int,
4034
help='project id of the project to process. You can add multiple project ids.')
4135
parser.add_argument('-o', '--output_path', required=None, default='/var/www/html', type=str,
42-
help='output path. please provide a location where the exported files should be stored.')
36+
help='output path. Provide a location for storing export files.')
37+
38+
####################################################################################################
4339

44-
########################################################################################################################
4540

4641

4742
def get_projects():

0 commit comments

Comments
 (0)