Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfox committed Dec 30, 2021
0 parents commit b24f2db
Show file tree
Hide file tree
Showing 115 changed files with 6,338 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.{js,py}]
charset = utf-8

[*.py]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

[lib/**.js]
indent_style = space
indent_size = 2

[{package.json,.travis.yml}]
indent_style = space
indent_size = 2

1 change: 1 addition & 0 deletions .flaskenv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FLASK_APP=sirendb.app
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
build_and_test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9.2'
architecture: 'x64'

- name: Update pip, wheel, and setuptools
run: pip install -U pip wheel setuptools

- name: Setup the virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
- name: Install dependencies
run: pip install -e .[dev]

- name: Run flake8
run: flake8 src tests

- name: Run tests
run: |
dbversion=$(createdb --version)
pgversion=$(python -c "import re; print(re.compile(r'createdb \(\S+\ ([^\.]+)').match('${dbversion}').groups()[0])")
export PATH=/usr/lib/postgresql/$pgversion/bin:$PATH
which pg_ctl
which createdb
which pg_config
coverage run -m pytest
coverage report
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__/
.venv/
.python-version
.env
*.egg-info/
*.sublime-*
etc/config.yml
.coverage
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SirenDB
=======

Requires Python 3.9+
32 changes: 32 additions & 0 deletions bin/get_chrome.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

cd $(dirname $0)

REVISION="866442"

if [ -d $REVISION ] ; then
echo "already installed"
exit
fi

echo $ZIP_URL
ZIP_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F$REVISION%2Fchrome-linux.zip?alt=media"

ZIP_FILE="${REVISION}-chrome-linux.zip"

echo "fetching $ZIP_URL"

rm -rf $REVISION
mkdir $REVISION
pushd $REVISION
curl -# $ZIP_URL > $ZIP_FILE
echo "unzipping.."
unzip $ZIP_FILE
popd
rm -f ./latest
ln -s $REVISION/chrome-linux/ ./latest

rm -rf chromedriver_linux64.zip chromedriver_linux64
wget http://chromedriver.storage.googleapis.com/90.0.4430.24/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
rm chromedriver_linux64.zip
18 changes: 18 additions & 0 deletions bin/get_nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -eu -o pipefail

cd $(dirname $0)

NGINX_VERSION="1.18.0"

if [ ! -d "nginx-${NGINX_VERSION}" ]; then
wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz";
tar -zxvf "nginx-${NGINX_VERSION}.tar.gz";
rm "nginx-${NGINX_VERSION}.tar.gz";
fi

cd "nginx-${NGINX_VERSION}"
PREFIX="$(cd .. && pwd)/nginx"
./configure --builddir=build --prefix=$PREFIX --with-poll_module --with-threads --with-file-aio
make install
39 changes: 39 additions & 0 deletions etc/logger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
version: 1
disable_existing_loggers: true
incremental: false

formatters:
default:
format: '%(asctime)-8s %(name)-25s %(levelname)-8s %(message)s'

handlers:
console:
class: logging.StreamHandler
level: DEBUG
formatter: default

loggers:
sirendb:
handlers: [console]
propagate: false
level: DEBUG
flask_migrate:
handlers: [console]
propagate: false
level: INFO
# sqlalchemy:
# handlers: [console]
# propagate: true
# level: DEBUG
# sqlalchemy.engine:
# handlers: [console]
# propagate: true
# level: INFO
# werkzeug:
# handlers: [console]
# propagate: false
# level: DEBUG

root:
handlers: [console]
level: DEBUG
95 changes: 95 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[metadata]
name = sirendb
author = Matt Ullman
author_email = [email protected]
description = Online Database for Outdoor Warning Sirens

[options]
packages = find:
package_dir = = src
include_package_data = True
python_requires = >= 3.9
install_requires =
alembic == 1.5.8
cached-property == 1.5.2
click == 7.1.2
croniter == 1.0.12
flask == 1.1.2
flask-cors == 3.0.10
flask-login == 0.5.0
flask-migrate == 2.7.0
flask-rq2 == 18.3
flask-sqlalchemy == 2.5.1
graphql-core == 3.1.3
greenlet == 1.0.0
hupper == 1.10.2
iniconfig == 1.1.1
itsdangerous == 1.1.0
jinja2 == 2.11.3
mako == 1.1.4
markupsafe == 1.1.1
psycopg2 == 2.8.6
pygments == 2.8.1
python-dateutil == 2.8.1
python-dotenv == 0.16.0
python-editor == 1.0.4
python-multipart == 0.0.5
pyyaml == 5.4.1
redis == 3.5.3
rq == 1.8.0
rq-scheduler == 0.11.0
selenium == 3.141.0
six == 1.15.0
sqlalchemy == 1.4.4
starlette == 0.14.2
# strawberry-graphql == 0.53.0
strawberry-graphql @ git+https://github.com/staticfox/strawberry@a16e760f21bfcfee975e395c4763bd3b3972a561#egg=strawberry
typing-extensions == 3.7.4.3
urllib3 == 1.26.4
werkzeug == 1.0.1

[options.extras_require]
dev =
attrs == 20.3.0
coverage == 5.5
fakeredis == 1.5.0
flake8 == 3.9.0
freezegun == 1.1.0
mccabe == 0.6.1
packaging == 20.9
pluggy == 0.13.1
py == 1.10.0
pycodestyle == 2.7.0
pyflakes == 2.3.1
pyparsing == 2.4.7
pytest == 6.2.2
sortedcontainers == 2.3.0
toml == 0.10.2

[options.packages.find]
where = src

[tool:pytest]
testpaths =
tests

[flake8]
max-line-length = 120
per-file-ignores =
# imported but unused
__init__.py: F401
exclude =
src/sirendb/migrations

[coverage:run]
source =
sirendb

[coverage:paths]
source =
src

[coverage:report]
show_missing = true
skip_covered = true
skip_empty = true
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
1 change: 1 addition & 0 deletions src/sirendb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import jobs
3 changes: 3 additions & 0 deletions src/sirendb/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from sirendb.web.flask import create_app

app = create_app()
Empty file added src/sirendb/core/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions src/sirendb/core/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from flask_login import LoginManager

login_manager = LoginManager()
3 changes: 3 additions & 0 deletions src/sirendb/core/db/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()
15 changes: 15 additions & 0 deletions src/sirendb/core/redis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from fakeredis import FakeRedis
from redis import Redis as Redis_

from sirendb.utils.lang import DelayedInstance


class Redis(DelayedInstance):
def init_app(self, app):
if app.testing:
self.set_instance(FakeRedis())
else:
self.set_instance(Redis_.from_url(app.config['APP_REDIS_URL']))


redis = Redis()
3 changes: 3 additions & 0 deletions src/sirendb/core/rq/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from flask_rq2 import RQ

rq = RQ()
4 changes: 4 additions & 0 deletions src/sirendb/core/strawberry/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .scalars import LimitedStringScalar
from .field import GraphQLField
from .schema import GraphQLSchema
from .type_ import GraphQLType
Loading

0 comments on commit b24f2db

Please sign in to comment.