Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
94eeef5
Work from the proof of concept (#2)
rbnswartz Jul 5, 2018
c176f62
Added support for overriding deploy bucket names
rbnswartz Aug 2, 2018
d2cdcae
Make converters and lambda handlers use the cdn bucket they are given
rbnswartz Aug 3, 2018
f54d078
Added environment variable to config
rbnswartz Aug 3, 2018
216da6f
Prod configuration
rbnswartz Sep 4, 2018
0cd3b1c
Fix configuration
rbnswartz Sep 4, 2018
1e06cc4
Merge branch 'develop'
rbnswartz Sep 4, 2018
9af71e8
Fixed a bug in the template update trigger
rbnswartz Sep 6, 2018
8446527
Fixed typo
rbnswartz Sep 7, 2018
e975d51
Fixed a bug in the redeployer
rbnswartz Sep 7, 2018
dfba21c
Added fix for region name and ignore all timestamps when rerendering
rbnswartz Sep 7, 2018
b5d4f1b
Added better status messages and remove uneeded code
rbnswartz Sep 7, 2018
e7772d4
Fixed a wrong bucket name
rbnswartz Sep 7, 2018
aed8007
See if this fixes the re-render issue
rbnswartz Sep 10, 2018
7998d44
Well that didn't do what I wanted reverting
rbnswartz Sep 10, 2018
3ecf91f
Attempting to get the print handler working
rbnswartz Sep 12, 2018
9eefe7d
Merge branch 'develop'
rbnswartz Sep 17, 2018
6a6c5e8
Fix chapter-appears-as-book-title bug.
aunger Aug 8, 2020
e6cf7a4
Fix register_modules URL in script.
aunger Aug 21, 2020
6158dc0
Fix markdown_linter name.
aunger Aug 21, 2020
525f423
Default to current AWS region.
aunger Aug 22, 2020
27b27f7
Improve debug and exception logging.
aunger Aug 21, 2020
a21214d
Match project links based on directory, not identifier.
aunger Sep 2, 2020
a2f2b89
Don't deploy via Travis
aunger Sep 3, 2020
3cb1442
Increase recursion limit
PurpleGuitar Sep 4, 2020
1db8261
Merge pull request #12 from WycliffeAssociates/cro-fix-recursion-over…
PurpleGuitar Sep 4, 2020
1233ecd
Merge pull request #11 from aunger/rba-no-travis-deploy
danparisd Sep 9, 2020
4242332
Merge pull request #10 from aunger/rba-aws-region
danparisd Sep 9, 2020
fb8e893
Merge pull request #9 from aunger/rba-register_modules
danparisd Sep 9, 2020
f477dfd
Merge pull request #8 from aunger/rba-links-from-indexhtml
danparisd Sep 9, 2020
9d08b8f
Merge pull request #6 from aunger/rba-logging
danparisd Sep 9, 2020
50c23e4
Merge pull request #3 from aunger/rba-book-names
danparisd Sep 9, 2020
84f2b09
update to node 10
danparisd Sep 9, 2020
b260ce2
Merge pull request #13 from WycliffeAssociates/dan-upgrade-node
danparisd Sep 9, 2020
0788d63
Increase recursion limit
PurpleGuitar Nov 24, 2020
8ab90eb
Fix tn links in tw
PurpleGuitar Jan 25, 2021
7f8a5c3
WIP added some tn tests
PurpleGuitar Jan 25, 2021
3623ec7
Changes for more tw rendering (#15)
rbnswartz Feb 3, 2021
32ae15e
Fixed an issue with a the title getting added as another chapter (#16)
rbnswartz May 20, 2021
a814a88
16dprice Jun 2, 2021
9f19a44
16dprice Jun 2, 2021
110b522
Jun 3, 2021
e8b7a5b
Jun 3, 2021
9f84af2
Jun 3, 2021
cf90c11
16dprice Jun 3, 2021
d5a3efe
16dprice Jun 3, 2021
5b514ae
Jun 4, 2021
b9d6f71
Jun 4, 2021
972bef3
16dprice Jun 4, 2021
03831c5
Merge branch 'develop' into cro-fix-d43-links
16dprice Jun 4, 2021
4194846
Revert "Merge branch 'develop' into cro-fix-d43-links"
16dprice Jun 4, 2021
0fdd4cd
Merge remote-tracking branch 'origin/cro-fix-d43-links' into cro-fix-…
16dprice Jun 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version: 3, 3.9, 3.8, 3.7, 3.6
FROM ubuntu:18.04

RUN apt update && apt install -y python python-pip build-essential git

RUN groupadd --gid 2000 vscode && useradd --uid 2000 --gid 2000 -m vscode

RUN pip install "pylint<2.0.0"
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/python-3
{
"name": "Python 2",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip install -r requirements.txt",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDE
*.swp

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
15 changes: 0 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,3 @@ after_success:
env:
global:
- PYTHONDONTWRITEBYTECODE=true

deploy:
- provider: script
skip_cleanup: true
script:
- scripts/deploy.sh && scripts/register_modules.sh https://dev-api.door43.org && scripts/integration_test.sh
on:
branch: develop
- provider: script
skip_cleanup: true
script:
- scripts/deploy.sh && scripts/register_modules.sh https://api.door43.org && scripts/integration_test.sh
on:
branch: master

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "Markdown linter in node.js. This is called in checkers/markdown_checker.py by lambda invoke",
"runtime": "nodejs6.10",
"runtime": "nodejs10.x",
"hooks": {
"build": "npm install",
"clean": "rm -rf node_modules"
Expand Down
2 changes: 1 addition & 1 deletion libraries/aws_tools/dynamodb_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class DynamoDBHandler(object):

def __init__(self, table_name, aws_access_key_id=None, aws_secret_access_key=None, aws_region_name='us-west-2'):
def __init__(self, table_name, aws_access_key_id=None, aws_secret_access_key=None, aws_region_name=None):
self.table_name = table_name
self.aws_access_key_id = aws_access_key_id
self.aws_secret_access_key = aws_secret_access_key
Expand Down
2 changes: 1 addition & 1 deletion libraries/aws_tools/lambda_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


class LambdaHandler(object):
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, aws_region_name='us-west-2'):
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, aws_region_name=None):
self.aws_access_key_id = aws_access_key_id
self.aws_secret_access_key = aws_secret_access_key
self.aws_region_name = aws_region_name
Expand Down
2 changes: 1 addition & 1 deletion libraries/aws_tools/s3_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class S3Handler(object):
def __init__(self, bucket_name=None, aws_access_key_id=None, aws_secret_access_key=None,
aws_region_name='us-west-2'):
aws_region_name=None):
self.bucket_name = bucket_name
self.aws_access_key_id = aws_access_key_id
self.aws_secret_access_key = aws_secret_access_key
Expand Down
2 changes: 1 addition & 1 deletion libraries/client/client_converter_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def process_callback(self):
self.job = TxJob.get(job_id)

if not self.job:
error = 'No job found for job_id = {0}, identifier = {0}'.format(job_id, self.identifier)
error = 'No job found for job_id = {0}, identifier = {1}'.format(job_id, self.identifier)
App.logger.error(error)
raise Exception(error)

Expand Down
21 changes: 15 additions & 6 deletions libraries/client/client_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def process_webhook(self):
job.source = self.source_url_base + "/" + file_key
job.cdn_bucket = App.cdn_bucket
job.cdn_file = 'tx/job/{0}.zip'.format(job.job_id)
job.output = 'https://{0}/{1}'.format(App.cdn_bucket, job.cdn_file)
job.output = 'http://{0}.s3-{1}.amazonaws.com/{2}'.format(App.cdn_bucket, App.aws_region_name, job.cdn_file)
job.callback = App.api_url + '/client/callback'
job.output_format = 'html'
job.links = {
Expand Down Expand Up @@ -218,7 +218,7 @@ def process_webhook(self):
book_job.job_id = self.get_unique_job_id()
book_job.identifier = '{0}/{1}/{2}/{3}'.format(book_job.job_id, book_count, i, book)
book_job.cdn_file = 'tx/job/{0}.zip'.format(book_job.job_id)
book_job.output = 'https://{0}/{1}'.format(App.cdn_bucket, book_job.cdn_file)
book_job.output = 'http://{0}.s3-{1}.amazonaws.com/{2}'.format(App.cdn_bucket, App.aws_region_name, book_job.cdn_file)
book_job.links = {
"href": "{0}/tx/job/{1}".format(App.api_url, book_job.job_id),
"rel": "self",
Expand Down Expand Up @@ -487,14 +487,23 @@ def get_converter_module(self, job):
converter = converters.filter(TxModule.resource_types.contains('other')).first()
return converter

def query_linters(self, resource_type = None, input_format = None):
query = TxModule.query().filter(TxModule.type == 'linter')
if input_format:
query = query.filter(TxModule.input_format.contains(input_format))
if resource_type:
query = query.filter(TxModule.resource_types.contains(resource_type))
return query

def get_linter_module(self, job):
"""
:param TxJob job:
:return TxModule:
"""
linters = TxModule.query().filter(TxModule.type=='linter') \
.filter(TxModule.input_format.contains(job.input_format))
linter = linters.filter(TxModule.resource_types.contains(job.resource_type)).first()
linter = self.query_linters(job.resource_type, job.input_format).first() or \
self.query_linters('other', job.input_format).first()
if not linter:
linter = linters.filter(TxModule.resource_types.contains('other')).first()
App.logger.debug("No matching linter for job {0}".format(job.__dict__))
linters = [row.__dict__ for row in self.query_linters()]
App.logger.debug("Available linters: {0}".format(linters))
return linter
66 changes: 66 additions & 0 deletions libraries/client/converters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import os
import json
import re
import codecs
from libraries.app.app import App


def txt2md(rootdir="."):
"""
Converts txt files to markdown
"""
proccessed = False
for dir, subdir, files in os.walk(rootdir):
for fname in files:
filepath = os.path.join(dir, fname)

if os.path.splitext(fname)[1] == ".txt":
with open(filepath, "r") as data_file:
# if content of the file starts from the valid json character
# then it's a json file
content = data_file.read().decode('utf-8')

if re.match(r"^\[|^\{", content):
try:
data = json.loads(content)
md = ""
for elm in data:
if "title" in elm and "body" in elm:
md += "# " + elm["title"] + "\n\n"
md += elm["body"] + "\n\n"

md_filepath = re.sub(r"\.txt$", ".md", filepath)
with codecs.open(md_filepath, "w", encoding="utf-8") as md_file:
md_file.write(md)

proccessed = True
except BaseException as e:
App.logger.debug('Error: {0}'.format(e.message))

if os.path.isfile(filepath):
os.remove(filepath)

return proccessed


def txt2usfm(rootdir="."):
"""
Converts txt files to usfm
"""
proccessed = False
for dir, subdir, files in os.walk(rootdir):
for fname in files:
filepath = os.path.join(dir, fname)

if os.path.splitext(fname)[1] == ".txt":
with open(filepath, "r") as data_file:
# if content of the file starts from the valid usfm chapter or verse tag
# then it's a usfm file
if re.match(r"^[\s]*\\c|^[\s]*\\v", data_file.read()):
proccessed = True

if proccessed and os.path.isfile(filepath):
usfm_filepath = re.sub(r"\.txt$", ".usfm", filepath)
os.rename(filepath, usfm_filepath)

return proccessed
Loading