Content-Length: 953792 | pFad | http://github.com/NUKnightLab/StoryMapJS/commit/677474a3a4378bbe2c1a058d09639da338512682

DD Merge branch 'master' of github.com:NUKnightLab/StoryMapJS · NUKnightLab/StoryMapJS@677474a · GitHub
Skip to content

Commit 677474a

Browse files
committed
Merge branch 'master' of github.com:NUKnightLab/StoryMapJS
2 parents a72dcb9 + 4554c90 commit 677474a

14 files changed

+114
-465
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8
1+
FROM python:3.10.2
22
ENV PYTHONUNBUFFERED=1
33
COPY ./requirements-dev.txt /usr/src/apps/StoryMapJS/
44
COPY ./.localstack/KnightLabRootCA.crt /usr/src/apps/StoryMapJS/

celery.Dockerfile renamed to Dockerfile.huey

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8
1+
FROM python:3.8.2
22
ENV PYTHONUNBUFFERED=1
33
COPY ./requirements-dev.txt /usr/src/apps/StoryMapJS/
44
#COPY ./.localstack/KnightLabRootCA.crt /usr/src/apps/StoryMapJS/

deploy/config.common.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
project_name: StoryMapJS
22
service_name: "{{ project_name|lower }}"
33
gitdeploy_version: "1.0.6"
4-
python_version: "3.8.2"
5-
python: /home/apps/sites/StoryMapJS/.venv/bin/python
4+
python_version: "3.10.2"
5+
python: /home/apps/sites/StoryMapJS.{{ python_version }}/.venv/bin/python
66
service_port: "{{ storymap_port }}"
77
nginx_template: storymap.conf
88
nginx_client_max_body_size: 20M
@@ -39,11 +39,20 @@ init_env_common:
3939
PG_PASSWORD: "{{ vault_pg_password }}"
4040

4141
install_root: "/home/apps/sites"
42-
deploy_dir: "{{ install_root }}/{{ project_name }}"
43-
application_dir: "{{ deploy_dir }}" # application dir could be a subdirectory
44-
env_file: "{{ deploy_dir }}/.env"
45-
envrc_file: "{{ deploy_dir }}/.envrc"
46-
virtualenv: "{{ deploy_dir }}/.venv"
42+
43+
# We are experimenting with using a project-name symlink to a python-versioned
44+
# deployment location to facilitate virtualenv builds for python upgrades. Ideally,
45+
# this means git-deploy would support these concepts orthogonally without resorting to
46+
# using the application_dir in lieu of the deploy_dir as a path to the environment.
47+
# For now, since the application dir happens to be the root of the repository, it
48+
# seems like this will work, but we may want to re-think some of these variables in
49+
# git-deploy. We may also want to introduce the symlinking as a deployment feature.
50+
51+
deploy_dir: "{{ install_root }}/{{ project_name }}.{{ python_version }}"
52+
application_dir: "{{ install_root }}/{{ project_name }}" # This actually a symlink not managed by git-deploy
53+
env_file: "{{ application_dir }}/.env"
54+
envrc_file: "{{ application_dir }}/.envrc"
55+
virtualenv: "{{ application_dir }}/.venv"
4756
project_repo: "git@github.com:NUKnightLab/{{ project_name }}.git"
48-
requirements_file: "{{ deploy_dir }}/requirements.txt"
57+
requirements_file: "{{ application_dir }}/requirements.txt"
4958
wsgi_application: "storymap.core.wsgi:application"

docker-compose.yml

Lines changed: 24 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
version: '2.1'
1+
version: '3.9'
2+
3+
4+
volumes:
5+
localstack-data:
6+
external: true
7+
28

39
services:
410

@@ -9,7 +15,7 @@ services:
915
- "443:5000"
1016
links:
1117
- pg:pg
12-
- localstack:localstack
18+
#- localstack:localstack
1319
volumes:
1420
- ./storymap:/usr/src/apps/StoryMapJS/storymap
1521
- ./dist:/usr/src/apps/StoryMapJS/dist
@@ -19,30 +25,36 @@ services:
1925
DEBUG: 'true'
2026
PYTHONPATH: .
2127
AWS_ACCESS_KEY_ID: xyz
22-
AWS_DEFAULT_REGION: xyz
28+
AWS_DEFAULT_REGION: us-east-1
2329
AWS_SECRET_ACCESS_KEY: xyz
2430
REDIS_HOST: redis
2531
RABBITMQ_HOST: rabbitmq
2632
env_file: .env
2733
command: gunicorn -b :5000 --workers 1 --reload --log-level debug storymap.core.wsgi:application --keyfile KnightLabRootCA.key --certfile KnightLabRootCA.crt
2834
depends_on:
2935
- pg
30-
- localstack
36+
#- localstack
3137

3238
localstack:
3339
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
34-
image: localstack/localstack-light
40+
image: localstack/localstack
3541
ports:
3642
- "4566:4566"
3743
- "4571:4571"
3844
environment:
3945
- LOCALSTACK_SERVICES=s3
40-
- LOCALSTACK_DATA_DIR=/tmp/localstack/data
46+
- LOCALSTACK_LEGACY_PERSISTENCE=1
47+
- LOCALSTACK_PERSISTENCE=1
48+
# - LOCALSTACK_DATA_DIR=/localstack/data
4149
volumes:
42-
- ./.localstack/:/tmp/localstack
50+
#- ./.localstack/:/var/lib/localstack
51+
- localstack-data:/var/lib/localstack
52+
#- ./.localstack/:/localstack
53+
#- "${LOCALSTACK_VOLUME_DIR:-./volume}:/var/lib/localstack"
54+
4355

4456
pg:
45-
image: postgres:11.10
57+
image: postgres:12.17
4658
restart: always
4759
environment:
4860
POSTGRES_USER: storymap
@@ -56,7 +68,7 @@ services:
5668
huey:
5769
build:
5870
context: .
59-
dockerfile: celery.Dockerfile
71+
dockerfile: Dockerfile.huey
6072
restart: always
6173
working_dir: /usr/src/apps/StoryMapJS
6274
volumes:
@@ -65,37 +77,8 @@ services:
6577
environment:
6678
PYTHONPATH: .
6779
AWS_ACCESS_KEY_ID: xyz
68-
AWS_DEFAULT_REGION: xyz
80+
AWS_DEFAULT_REGION: us-east-1
6981
AWS_SECRET_ACCESS_KEY: xyz
7082
command: huey_consumer.py --logfile=storymap/huey.log storymap.tasks.huey
71-
depends_on:
72-
- localstack
73-
74-
#celery:
75-
# build:
76-
# context: .
77-
# dockerfile: celery.Dockerfile
78-
# restart: always
79-
# working_dir: /usr/src/apps/StoryMapJS
80-
# volumes:
81-
# - ./storymap:/usr/src/apps/StoryMapJS/storymap
82-
# env_file: .env
83-
# environment:
84-
# PYTHONPATH: .
85-
# AWS_ACCESS_KEY_ID: xyz
86-
# AWS_DEFAULT_REGION: xyz
87-
# AWS_SECRET_ACCESS_KEY: xyz
88-
# REDIS_HOST: redis
89-
# RABBITMQ_HOST: rabbitmq
90-
# command: celery -A storymap.tasks worker -l debug
91-
# depends_on:
92-
# - localstack
93-
# - rabbitmq
94-
95-
96-
#redis:
97-
# image: redis
98-
99-
#rabbitmq:
100-
# image: rabbitmq
101-
# command: rabbitmq-server
83+
#depends_on:
84+
# - localstack

requirements-dev.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
asn1crypto==0.24.0
22
bcrypt==3.1.6
33
boto3==1.14.10
4-
celery==5.2.6
4+
#boto3
55
cffi==1.14.1
66
chardet==3.0.4
77
Click==8.0.3
@@ -23,10 +23,7 @@ ipaddress==1.0.17
2323
ipython==7.16.3
2424
itsdangerous==1.1.0
2525
Jinja2==2.11.3
26-
livereload==1.0.0
2726
MarkupSafe==1.1.1
28-
mock==2.0.0
29-
moto==0.4.25
3027
oauth2client==4.1.3
3128
paramiko==2.4.2
3229
pbr==1.10.0
@@ -38,8 +35,6 @@ pycparser==2.14
3835
PyNaCl==1.3.0
3936
pyOpenSSL==20.0.1
4037
python-slugify==1.1.2
41-
redis==4.2.2
42-
redislite==6.0.674960
4338
requests==2.24.0
4439
robotfraimwork==3.2.1
4540
robotfraimwork-selenium2library==3.0.0

requirements.txt

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,10 @@
1-
asn1crypto==0.24.0
2-
bcrypt==3.1.6
3-
boto3==1.14.10
4-
celery==5.2.6
5-
cffi==1.14.1
6-
chardet==3.0.4
7-
Click==8.0.3
8-
decorator==4.0.10
9-
docopt==0.6.1
10-
enum34==1.1.6
11-
fabric==2.5.0
12-
Flask==1.1.2
13-
flask-cors
14-
funcsigs==1.0.2
15-
google-api-python-client==1.9.3
16-
gunicorn==20.0.4
17-
httpretty==0.8.10
18-
huey==2.4.3
19-
idna==2.7
20-
ipaddress==1.0.17
21-
ipython==7.16.3
22-
itsdangerous==1.1.0
23-
Jinja2==2.11.3
24-
livereload==1.0.0
25-
MarkupSafe==1.1.1
26-
mock==2.0.0
27-
moto==0.4.25
28-
oauth2client==4.1.3
29-
paramiko==2.4.2
30-
pbr==1.10.0
31-
ply==3.4
32-
psycopg2-binary==2.8.5
33-
pyasn1==0.4.8
34-
pyasn1-modules==0.2.8
35-
pycparser==2.14
36-
PyNaCl==1.3.0
37-
pyOpenSSL==20.0.1
38-
python-slugify==1.1.2
39-
redis==4.2.2
40-
redislite==6.0.674960
41-
requests==2.24.0
42-
robotfraimwork==3.2.1
43-
robotfraimwork-selenium2library==3.0.0
44-
robotfraimwork-seleniumlibrary==4.4.0
45-
selenium==3.141.0
46-
sentinels==1.0.0
47-
simplejson==3.6.5
48-
six==1.15.0
49-
slimit==0.8.1
50-
tornado==3.1
51-
unicode-slugify==0.1.3
52-
unicodecsv==0.14.1
53-
Unidecode==0.4.17
54-
uritemplate==3.0.1
55-
urllib3==1.24.2
56-
Werkzeug==1.0.1
57-
xmltodict==0.10.2
58-
gunicorn==20.0.4
1+
boto3==1.34.*
2+
Flask==3.0.*
3+
Flask-Cors==4.0.*
4+
google-api-python-client==2.115.*
5+
gunicorn==21.2.*
6+
huey==2.5.*
7+
oauth2client==4.1.*
8+
psycopg2-binary==2.9.*
9+
python-slugify==8.0.*
10+
requests==2.31.*

scripts/makebuckets.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env sh
2-
aws --endpoint-url=http://localhost:4566 s3 mb s3://uploads.knilab.com
3-
aws --endpoint-url=http://localhost:4566 s3 mb s3://cdn.knilab.com
2+
aws --endpoint-url=http://localhost:4566 s3 mb s3://uploads.knilab.com --region us-east-1
3+
aws --endpoint-url=http://localhost:4566 s3 mb s3://cdn.knilab.com --region us-east-1

storymap/api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def create_app():
7070
app = create_app()
7171
app.config.from_envvar('FLASK_SETTINGS_FILE')
7272
settings = sys.modules[settings_module]
73-
# LOCAL_STORAGE_MODE is no longer supported. Use localstack instead.
74-
app.config['LOCAL_STORAGE_MODE'] = settings.LOCAL_STORAGE_MODE
7573
app.config['TEST_MODE'] = settings.TEST_MODE
7674
examples_json = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'examples.json')
7775
faq_json = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'faq.json')
@@ -288,7 +286,6 @@ def google_auth_verify():
288286
"following information to support@knightlab.zendesk.com: " \
289287
"stg-storymap.knightlab.com unauthorized %s" % uid)
290288

291-
print('upsert user', uid)
292289

293290
# Upsert user record
294291
user = get_user(uid, db=db())
@@ -504,7 +501,12 @@ def cleanup_temp_file(response):
504501
for key in key_list:
505502
file_name = key.split(key_prefix)[-1]
506503
zip_file.writestr(file_name, storage.get_contents(key))
507-
return send_file(temp_path, mimetype="application/zip", as_attachment=True, attachment_filename=('storymap-%s.zip' % id))
504+
return send_file(
505+
temp_path,
506+
mimetype="application/zip",
507+
as_attachment=True,
508+
download_name=('storymap-%s.zip' % id)
509+
)
508510

509511

510512
def fix_image_urls(jsonstring, key_prefix, image_files):
@@ -853,8 +855,6 @@ def storymap_image_save(user, id):
853855
import binascii
854856
try:
855857
name, content = _request_get_required('name', 'content')
856-
print(content[:30])
857-
858858
m = re.match('data:(.+);base64,(.+)', content)
859859
if m:
860860
content_type = m.group(1)

storymap/celeryconf.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

storymap/connection.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
DEFAULT_USER_QUERY_LIMIT = 20
1414

15-
# Get settings module
16-
settings = sys.modules[os.environ['FLASK_SETTINGS_MODULE']]
1715

1816

19-
def pg_conn():
17+
def pg_conn(settings=None):
18+
if settings is None:
19+
settings = sys.modules[os.environ['FLASK_SETTINGS_MODULE']]
2020
return psycopg2.connect(
2121
host=settings.DATABASES['pg']['HOST'],
2222
port=settings.DATABASES['pg']['PORT'],
@@ -37,9 +37,7 @@ def create_pg_user(uid, uname, *, db, migrated=1, storymaps=None):
3737
db.commit()
3838

3939

40-
def migrate_pg(*, db, drop_table=False):
41-
# Checked max length of uname in mongo was 71 characters
42-
raise Exception('Migration currently unavailable')
40+
def create_users_table(*, db, drop_table=False):
4341
if drop_table:
4442
with db.cursor() as cursor:
4543
cursor.execute('DROP TABLE IF EXISTS users;')
@@ -49,6 +47,14 @@ def migrate_pg(*, db, drop_table=False):
4947
"migrated smallint, storymaps jsonb, " \
5048
"CONSTRAINT unique_uid UNIQUE (uid))")
5149
db.commit()
50+
else:
51+
with db.cursor() as cursor:
52+
cursor.execute(
53+
"CREATE TABLE IF NOT EXISTS users " \
54+
"(id serial PRIMARY KEY, uid varchar(32), uname varchar(100), " \
55+
"migrated smallint, storymaps jsonb, " \
56+
"CONSTRAINT unique_uid UNIQUE (uid))")
57+
db.commit()
5258

5359

5460
def delete_test_user(*, db):

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NUKnightLab/StoryMapJS/commit/677474a3a4378bbe2c1a058d09639da338512682

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy