-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ pip-log.txt | |
# Mac OS X | ||
.DS_Store | ||
|
||
.mypy_cache | ||
private_settings.py | ||
local_settings.py | ||
media/images | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.7 | ||
|
||
WORKDIR /app | ||
ARG requirements=requirements.txt | ||
|
||
ADD . /app | ||
|
||
RUN pip install --no-cache-dir -e . | ||
RUN pip install --no-cache-dir -r $requirements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
PROJECT_NAME=infomate | ||
|
||
all: run | ||
|
||
# Install dev requirements | ||
dev-requirements: | ||
@pip3 install -r requirements.txt | ||
|
||
# Migrate database to the latest version | ||
migrate: | ||
@python3 manage.py migrate | ||
|
||
# Check types with mypy | ||
mypy: | ||
mypy $(PROJECT_NAME) | ||
|
||
# Lint code with flake8 | ||
lint: | ||
flake8 $(PROJECT_NAME) | ||
|
||
# Runs dev server | ||
run: | ||
@python3 manage.py runserver | ||
|
||
# Run dev server in docker | ||
docker_run: | ||
@python3 ./utils/wait_for_postgres.py | ||
@python3 manage.py migrate | ||
@python3 manage.py runserver | ||
|
||
# Initialize feeds from boards.yml | ||
feed_init: | ||
@python3 ./scripts/initialize.py | ||
|
||
# Refresh RSS feeds | ||
feed_refresh: | ||
@python3 ./scripts/update.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
# infomate.club | ||
|
||
Experimental project | ||
|
||
### Run | ||
|
||
``` | ||
$ docker-compose up | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '3.7' | ||
|
||
services: | ||
infomate_app: | ||
build: | ||
context: . | ||
args: | ||
requirements: requirements.txt | ||
command: make docker_run | ||
container_name: infomate_app | ||
environment: | ||
- DEBUG=True | ||
- PYTHONUNBUFFERED=1 | ||
restart: always | ||
volumes: | ||
- .:/app:delegated | ||
depends_on: | ||
- postgres | ||
ports: | ||
- "8000:8000" | ||
|
||
postgres: | ||
image: postgres:11 | ||
container_name: infomate_postgres | ||
environment: | ||
- POSTGRES_USER=postgres | ||
- POSTGRES_PASSWORD=postgres | ||
- POSTGRES_DB=infomate | ||
ports: | ||
- 5432 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[mypy] | ||
ignore_missing_imports = True | ||
|
||
check_untyped_defs = True | ||
disallow_any_generics = True | ||
disallow_untyped_defs = True | ||
follow_imports = silent | ||
strict_optional = True | ||
warn_redundant_casts = True | ||
warn_unused_ignores = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
max-line-length = 119 | ||
exclude = etc static templates migrations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
import re | ||
import pathlib | ||
from typing import List | ||
|
||
from setuptools import find_packages, setup | ||
|
||
REGEXP = re.compile(r'^__version__\W*=\W*"([\d.abrc]+)"') | ||
PARENT = pathlib.Path(__file__).parent | ||
|
||
|
||
def read_version(): | ||
init_py = os.path.join( | ||
os.path.dirname(__file__), | ||
"infomate", | ||
"__init__.py", | ||
) | ||
|
||
with open(init_py) as f: | ||
for line in f: | ||
match = REGEXP.match(line) | ||
if match is not None: | ||
return match.group(1) | ||
else: | ||
msg = f"Cannot find version in ${init_py}" | ||
raise RuntimeError(msg) | ||
|
||
|
||
def read_requirements(path: str) -> List[str]: | ||
file_path = PARENT / path | ||
with open(file_path) as f: | ||
return f.read().split("\n") | ||
|
||
|
||
setup( | ||
name="infomate", | ||
version=read_version(), | ||
description="infomate", | ||
platforms=["POSIX"], | ||
packages=find_packages(), | ||
package_data={ | ||
"": ["docs/*.*"] | ||
}, | ||
include_package_data=True, | ||
install_requires=read_requirements("requirements.txt"), | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import socket | ||
import time | ||
import random | ||
|
||
if __name__ == "__main__": | ||
while True: | ||
try: | ||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: | ||
sock.connect(("postgres", 5432)) | ||
print("Postgres had started") | ||
break | ||
except socket.error: | ||
print("Waiting for postgres") | ||
time.sleep(0.5 + (random.randint(0, 100) / 1000)) |