Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored API code into subpackage #56

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ verify_ssl = true
name = "pypi"

[packages]
aw-core = {ref = "master",git = "https://github.com/ActivityWatch/aw-core.git"}
aw_core = {editable = true, path = "../aw-core"}
aw-server = {editable = true, path = "."}
flask-restplus = ">=0.9.2"
appdirs = ">=1.4.0"
python-json-logger = ">=0.1.5"
Expand Down
64 changes: 51 additions & 13 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion aw_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
from .server import create_app

from . import api
from . import rest
from . import resources

from .main import main
3 changes: 1 addition & 2 deletions aw_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
from .server import _start
from .config import config

logger = logging.getLogger(__name__)


def main():
"""Called from the executable and __main__.py"""
Expand All @@ -23,6 +21,7 @@ def main():
setup_logging("aw-server", testing=settings.testing, verbose=settings.verbose,
log_stderr=True, log_file=True, log_file_json=False)

logger = logging.getLogger(__name__)
logger.info("Using storage method: {}".format(settings.storage))

if settings.testing:
Expand Down
Empty file added aw_server/resources/__init__.py
Empty file.
7 changes: 4 additions & 3 deletions aw_server/rest.py → aw_server/resources/rest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Dict
import traceback
import json
import logging

from flask import request, Blueprint, jsonify, current_app, make_response
from flask_restplus import Api, Resource, fields
Expand All @@ -10,11 +11,11 @@
from aw_core import schema
from aw_core.models import Event

from . import logger
from .api import ServerAPI
from .exceptions import BadRequest, Unauthorized
from aw_server.api import ServerAPI
from aw_server.exceptions import BadRequest, Unauthorized
from aw_analysis.query2_error import QueryException

logger = logging.getLogger(__name__)

# SECURITY
# As we work our way through features, disable (while this is False, we should only accept connections from localhost)
Expand Down
6 changes: 3 additions & 3 deletions aw_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import aw_datastore
from aw_datastore import Datastore

from .log import FlaskLogHandler
from .api import ServerAPI
from . import rest
from aw_server.log import FlaskLogHandler
from aw_server.api import ServerAPI
from aw_server.resources import rest


logger = logging.getLogger(__name__)
Expand Down
8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError: # for pip <= 9.0.3
from pip.req import parse_requirements

from setuptools import setup
from setuptools import setup, find_packages

here = os.path.abspath(os.path.dirname(__file__))

Expand All @@ -22,14 +22,18 @@

requirements = parse_requirements("./requirements.txt", session=False)

packages = find_packages()
if packages != ["aw_server", "aw_server.resources"]:
print(f"Found extra packages: {packages}")

setup(name='aw-server',
version=about["__version__"],
description='ActivityWatch server',
long_description=readme,
author='Erik Bjäreholt',
author_email='[email protected]',
url='https://github.com/ActivityWatch/aw-server',
packages=['aw_server'],
packages=packages,
include_package_data=True,
install_requires=[str(requirement.req) for requirement in requirements],
entry_points={
Expand Down