diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..8f5d57d --- /dev/null +++ b/setup.py @@ -0,0 +1,28 @@ +import os +from setuptools import setup, find_packages + +ROOT = os.path.dirname(__name__) + +setup( + name='CommentServer', + version='0.0.1', + packages=find_packages(exclude=('tests',)), + entry_points={ + 'console_scripts': 'commentserv=src.main:main' + }, + zip_safe=False, + data_files=[('config', ['config/conf.json',])], + include_package_data=True, + install_requires=[ + 'Faker>=1.0.7', + 'asyncio>=3.4.3', + 'aiohttp==3.5.4', + 'aiojobs==0.2.2', + 'ecdsa==0.13', + 'cryptography==2.5', + 'aiosqlite==0.10.0', + 'PyNaCl>=1.3.0', + 'requests', + 'cython', # Not really needed anymore but w/e + ] +) diff --git a/main.py b/src/main.py similarity index 98% rename from main.py rename to src/main.py index 293d625..2377c6d 100644 --- a/main.py +++ b/src/main.py @@ -2,8 +2,7 @@ import logging.config import logging import os from src.settings import config - -from src.app import run_app +from src.server.app import run_app def config_logging_from_settings(conf): diff --git a/src/server/__init__.py b/src/server/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/app.py b/src/server/app.py similarity index 96% rename from src/app.py rename to src/server/app.py index ea916da..39fda5b 100644 --- a/src/app.py +++ b/src/server/app.py @@ -11,8 +11,8 @@ import asyncio from aiohttp import web from src.schema.db_helpers import setup_database, backup_database -from src.database import obtain_connection, DatabaseWriter -from src.handles import api_endpoint, get_api_endpoint +from src.server.database import obtain_connection, DatabaseWriter +from src.server.handles import api_endpoint, get_api_endpoint logger = logging.getLogger(__name__) diff --git a/src/database.py b/src/server/database.py similarity index 100% rename from src/database.py rename to src/server/database.py diff --git a/src/handles.py b/src/server/handles.py similarity index 84% rename from src/handles.py rename to src/server/handles.py index 2dad791..ada8449 100644 --- a/src/handles.py +++ b/src/server/handles.py @@ -6,15 +6,15 @@ import asyncio from aiohttp import web from aiojobs.aiohttp import atomic -from src.misc import clean_input_params -from src.database import get_claim_comments -from src.database import get_comments_by_id, get_comment_ids -from src.database import get_channel_id_from_comment_id -from src.database import obtain_connection -from src.misc import is_valid_base_comment -from src.misc import is_valid_credential_input -from src.misc import make_error -from src.writes import delete_comment_if_authorized, write_comment +from src.server.misc import clean_input_params +from src.server.database import get_claim_comments +from src.server.database import get_comments_by_id, get_comment_ids +from src.server.database import get_channel_id_from_comment_id +from src.server.database import obtain_connection +from src.server.misc import is_valid_base_comment +from src.server.misc import is_valid_credential_input +from src.server.misc import make_error +from src.server.writes import delete_comment_if_authorized, write_comment logger = logging.getLogger(__name__) @@ -25,22 +25,22 @@ def ping(*args): def handle_get_channel_from_comment_id(app, kwargs: dict): - with obtain_connection(app['db_path']) as conn: + with app['reader'] as conn: return get_channel_id_from_comment_id(conn, **kwargs) def handle_get_comment_ids(app, kwargs): - with obtain_connection(app['db_path']) as conn: + with app['reader'] as conn: return get_comment_ids(conn, **kwargs) def handle_get_claim_comments(app, kwargs): - with obtain_connection(app['db_path']) as conn: + with app['reader'] as conn: return get_claim_comments(conn, **kwargs) def handle_get_comments_by_id(app, kwargs): - with obtain_connection(app['db_path']) as conn: + with app['reader'] as conn: return get_comments_by_id(conn, **kwargs) diff --git a/src/misc.py b/src/server/misc.py similarity index 100% rename from src/misc.py rename to src/server/misc.py diff --git a/src/writes.py b/src/server/writes.py similarity index 83% rename from src/writes.py rename to src/server/writes.py index 1b11e76..2feb928 100644 --- a/src/writes.py +++ b/src/server/writes.py @@ -3,13 +3,13 @@ import sqlite3 from asyncio import coroutine -from src.database import delete_comment_by_id -from src.misc import is_authentic_delete_signal +from src.server.database import delete_comment_by_id +from src.server.misc import is_authentic_delete_signal -from src.database import get_comment_or_none -from src.database import insert_comment -from src.database import insert_channel -from src.misc import channel_matches_pattern_or_error +from src.server.database import get_comment_or_none +from src.server.database import insert_comment +from src.server.database import insert_channel +from src.server.misc import channel_matches_pattern_or_error logger = logging.getLogger(__name__)