diff --git a/.gitignore b/.gitignore index 0707a32..6c9203b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ *.pyc - docs_src/build/ - +build +dist +.idea +*.log +cbpi.egg-info \ No newline at end of file diff --git a/.idea/craftbeerpi4.iml b/.idea/craftbeerpi4.iml index 7857219..f9cabb2 100644 --- a/.idea/craftbeerpi4.iml +++ b/.idea/craftbeerpi4.iml @@ -2,13 +2,14 @@ - + + - \ No newline at end of file diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index 2488295..a5d569c 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -14,5 +14,23 @@ false *:@ + + + + false + *:@ + + + + + false + *:@ + + + + + false + *:@ + \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index a24bede..9b913ae 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -27,5 +27,56 @@ + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/test/craftbeerpi.db + + + + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/xerial-sqlite-license.txt + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/sqlite-jdbc-3.16.1.jar + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/test22/craftbeerpi.db + + + + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/xerial-sqlite-license.txt + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/sqlite-jdbc-3.16.1.jar + + + + + sqlite.xerial + true + org.sqlite.JDBC + jdbc:sqlite:$PROJECT_DIR$/cbpi/craftbeerpi.db + + + + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/xerial-sqlite-license.txt + + + file://$APPLICATION_CONFIG_DIR$/jdbc-drivers/Xerial SQLiteJDBC/3.16.1/sqlite-jdbc-3.16.1.jar + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d8b89b4..fbfb8e4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,39 +2,105 @@ + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -53,16 +121,17 @@ - + - + + - + + + + + + + + - - - - - - - - @@ -356,6 +437,28 @@ + + + + + + + + + - - - - - - - - - @@ -557,7 +656,7 @@ - + 1541288846149 @@ -577,18 +676,6 @@ - - - - - - - - - - - - @@ -607,9 +694,21 @@ + + + + + + + + + + + + - @@ -622,16 +721,17 @@ + - + - - + + @@ -643,40 +743,13 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - + + - - - - - - + + - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + + + + + + + - - - - + + + + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -919,120 +1005,103 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - - + + - + - - - - - - - - + + - + - - + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1041,82 +1110,24 @@ - + - - - - - + + - - - - - - - - + - - - - + + - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Dockerfile b/Dockerfile index ae7a12c..4252cd3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,14 @@ -FROM python:3 +FROM python:3.5.6-stretch WORKDIR /usr/src/app -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +COPY dist/cbpi-0.0.1.tar.gz ./ +RUN pip install cbpi-0.0.1.tar.gz --no-cache-dir COPY . . EXPOSE 8080 -CMD [ "python", "./run.py" ] +CMD [ "cbpi" ] diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..e6120c3 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include cbpi/config * +recursive-include cbpi/extension * \ No newline at end of file diff --git a/core/__init__.py b/cbpi/__init__.py similarity index 100% rename from core/__init__.py rename to cbpi/__init__.py diff --git a/cbpi/api/__init__.py b/cbpi/api/__init__.py new file mode 100644 index 0000000..9b3a8ed --- /dev/null +++ b/cbpi/api/__init__.py @@ -0,0 +1,27 @@ +__all__ = ["CBPiActor", + "CBPiExtension", + "Property", + "PropertyType", + "on_websocket_message", + "on_mqtt_message", + "on_event", + "on_startup", + "request_mapping", + "action", + "background_task", + "CBPiKettleLogic", + "CBPiSimpleStep", + "CBPiException", + "KettleException", + "SensorException", + "ActorException", + "CBPiSensor"] + +from cbpi.api.actor import * +from cbpi.api.sensor import * +from cbpi.api.extension import * +from cbpi.api.property import * +from cbpi.api.decorator import * +from cbpi.api.kettle_logic import * +from cbpi.api.step import * +from cbpi.api.exceptions import * \ No newline at end of file diff --git a/cbpi/api/actor.py b/cbpi/api/actor.py new file mode 100644 index 0000000..07271db --- /dev/null +++ b/cbpi/api/actor.py @@ -0,0 +1,49 @@ +from abc import ABCMeta + +from cbpi.api.extension import CBPiExtension + +__all__ = ["CBPiActor"] + +import logging + + +logger = logging.getLogger(__file__) + +class CBPiActor(CBPiExtension, metaclass=ABCMeta): + + def init(self): + pass + + def stop(self): + pass + + def on(self, power): + ''' + Code to switch the actor on. Power is provided as integer value + + :param power: power value between 0 and 100 + :return: None + ''' + pass + + def off(self): + + ''' + Code to switch the actor off + + :return: None + ''' + pass + + def state(self): + + ''' + Return the current actor state + + :return: + ''' + + pass + + def reprJSON(self): + return dict(state=True) \ No newline at end of file diff --git a/cbpi/api/config.py b/cbpi/api/config.py new file mode 100644 index 0000000..35ed0ea --- /dev/null +++ b/cbpi/api/config.py @@ -0,0 +1,8 @@ +from enum import Enum + +class ConfigType(Enum): + STRING = "string" + NUMBER = "number" + SELECT = "select" + + diff --git a/cbpi/api/decorator.py b/cbpi/api/decorator.py new file mode 100644 index 0000000..83a02c8 --- /dev/null +++ b/cbpi/api/decorator.py @@ -0,0 +1,96 @@ +__all__ = ["request_mapping", "on_startup", "on_event", "on_mqtt_message", "on_websocket_message", "action", "background_task"] + +from aiohttp_auth import auth + +def composed(*decs): + def deco(f): + for dec in reversed(decs): + f = dec(f) + return f + return deco + +def request_mapping(path, name=None, method="GET", auth_required=True): + + def on_http_request(path, name=None): + def real_decorator(func): + func.route = True + func.path = path + func.name = name + func.method = method + return func + + return real_decorator + + if auth_required is True: + return composed( + on_http_request(path, name), + auth.auth_required + ) + else: + return composed( + on_http_request(path, name) + ) + +def on_websocket_message(path, name=None): + def real_decorator(func): + func.ws = True + func.key = path + func.name = name + return func + + return real_decorator + +def on_event(topic): + def real_decorator(func): + func.eventbus = True + func.topic = topic + func.c = None + return func + + return real_decorator + +def action(key, parameters): + def real_decorator(func): + func.action = True + + func.key = key + func.parameters = parameters + return func + + return real_decorator + +def on_mqtt_message(topic): + def real_decorator(func): + func.mqtt = True + func.topic = topic + return func + + return real_decorator + + +def background_task(name, interval): + def real_decorator(func): + func.background_task = True + func.name = name + func.interval = interval + return func + + return real_decorator + + +def on_startup(name, order=0): + def real_decorator(func): + func.on_startup = True + func.name = name + func.order = order + return func + + return real_decorator + + +def entry_exit(f): + def new_f(): + + f() + + return new_f \ No newline at end of file diff --git a/cbpi/api/exceptions.py b/cbpi/api/exceptions.py new file mode 100644 index 0000000..77af2f6 --- /dev/null +++ b/cbpi/api/exceptions.py @@ -0,0 +1,14 @@ +__all__ = ["CBPiException","KettleException","SensorException","ActorException"] + + +class CBPiException(Exception): + pass + +class KettleException(CBPiException): + pass + +class SensorException(CBPiException): + pass + +class ActorException(CBPiException): + pass \ No newline at end of file diff --git a/cbpi/api/extension.py b/cbpi/api/extension.py new file mode 100644 index 0000000..23f0c77 --- /dev/null +++ b/cbpi/api/extension.py @@ -0,0 +1,54 @@ +import logging +import os +import sys + +import yaml + +__all__ = ["CBPiExtension"] + + + +logger = logging.getLogger(__file__) + + + +class CBPiExtension(): + + def init(self): + pass + + def stop(self): + pass + + def __init__(self, *args, **kwds): + + for a in kwds: + logger.debug("Parameter: %s Value: %s" % ( a, kwds.get(a))) + super(CBPiExtension, self).__setattr__(a, kwds.get(a)) + self.cbpi = kwds.get("cbpi") + self.id = kwds.get("id") + self.value = None + self.__dirty = False + + def __setattr__(self, name, value): + + if name != "_CBPiExtension__dirty": + self.__dirty = True + super(CBPiExtension, self).__setattr__(name, value) + else: + super(CBPiExtension, self).__setattr__(name, value) + + def load_config(self): + + path = os.path.dirname(sys.modules[self.__class__.__module__].__file__) + + try: + with open("%s/config.yaml" % path, 'rt') as f: + data = yaml.load(f) + + return data + except: + logger.warning("Faild to load config %s/config.yaml" % path) + + + diff --git a/cbpi/api/kettle_logic.py b/cbpi/api/kettle_logic.py new file mode 100644 index 0000000..210c9ae --- /dev/null +++ b/cbpi/api/kettle_logic.py @@ -0,0 +1,38 @@ +from cbpi.api.extension import CBPiExtension + + +class CBPiKettleLogic(CBPiExtension): + + ''' + Base Class for a Kettle logic. + ''' + + def init(self): + ''' + Code which will be executed when the logic is initialised. Needs to be overwritten by the implementing logic + + :return: None + ''' + pass + + def stop(self): + ''' + Code which will be executed when the logic is stopped. Needs to be overwritten by the implementing logic + + + :return: None + ''' + pass + + def run(self): + ''' + This method is running as background process when logic is started. + Typically a while loop responsible that the method keeps running + + while self.running: + await asyncio.sleep(1) + + :return: None + ''' + + pass \ No newline at end of file diff --git a/cbpi/api/property.py b/cbpi/api/property.py new file mode 100644 index 0000000..98f44ca --- /dev/null +++ b/cbpi/api/property.py @@ -0,0 +1,113 @@ +__all__ = ["PropertyType", "Property"] + +class PropertyType(object): + pass + +class Property(object): + class Select(PropertyType): + + ''' + Select Property. The user can select value from list set as options parameter + ''' + + def __init__(self, label, options, description=""): + ''' + + :param label: + :param options: + :param description: + ''' + PropertyType.__init__(self) + self.label = label + self.options = options + self.description = description + + class Number(PropertyType): + + ''' + The user can set a number value + ''' + def __init__(self, label, configurable=False, default_value=None, unit="", description=""): + ''' + Test + + + :param label: + :param configurable: + :param default_value: + :param unit: + :param description: + ''' + PropertyType.__init__(self) + self.label = label + self.configurable = configurable + self.default_value = default_value + self.description = description + + class Text(PropertyType): + + ''' + The user can set a text value + ''' + def __init__(self, label, configurable=False, default_value="", description=""): + ''' + + :param label: + :param configurable: + :param default_value: + :param description: + ''' + PropertyType.__init__(self) + self.label = label + self.configurable = configurable + self.default_value = default_value + self.description = description + + class Actor(PropertyType): + + ''' + The user select an actor which is available in the system. The value of this variable will be the actor id + ''' + def __init__(self, label, description=""): + ''' + + :param label: + :param description: + ''' + PropertyType.__init__(self) + self.label = label + self.configurable = True + self.description = description + + class Sensor(PropertyType): + ''' + The user select a sensor which is available in the system. The value of this variable will be the sensor id + ''' + + def __init__(self, label, description=""): + ''' + + :param label: + :param description: + ''' + PropertyType.__init__(self) + self.label = label + self.configurable = True + self.description = description + + class Kettle(PropertyType): + ''' + The user select a kettle which is available in the system. The value of this variable will be the kettle id + ''' + + def __init__(self, label, description=""): + ''' + + :param label: + :param description: + ''' + + PropertyType.__init__(self) + self.label = label + self.configurable = True + self.description = description \ No newline at end of file diff --git a/cbpi/api/sensor.py b/cbpi/api/sensor.py new file mode 100644 index 0000000..a7c4909 --- /dev/null +++ b/cbpi/api/sensor.py @@ -0,0 +1,38 @@ +from logging.handlers import RotatingFileHandler +from time import localtime, strftime + +from cbpi.api.extension import CBPiExtension +import logging + + +class CBPiSensor(CBPiExtension): + def __init__(self, *args, **kwds): + CBPiExtension.__init__(self, *args, **kwds) + self.logger = logging.getLogger(__file__) + self.data_logger = None + + + + def log_data(self, value): + + formatted_time = strftime("%Y-%m-%d %H:%M:%S", localtime()) + + self.data_logger.debug("%s,%s" % (formatted_time, value)) + + + def init(self): + + + self.data_logger = logging.getLogger('cbpi.sensor.%s' % self.id) + self.data_logger.propagate = False + self.data_logger.setLevel(logging.DEBUG) + handler = RotatingFileHandler('./logs/sensors/sensor_%s.log' % self.id, maxBytes=2000, backupCount=10) + self.data_logger.addHandler(handler) + pass + + + async def run(self, cbpi): + self.logger.warning("Sensor Init not implemented") + + def state(self): + pass \ No newline at end of file diff --git a/cbpi/api/step.py b/cbpi/api/step.py new file mode 100644 index 0000000..08c2626 --- /dev/null +++ b/cbpi/api/step.py @@ -0,0 +1,134 @@ +import time +import asyncio +import logging +from abc import abstractmethod,ABCMeta + + +class CBPiSimpleStep(metaclass=ABCMeta): + + __dirty = False + managed_fields = [] + _interval = 0.1 + _max_exceptions = 2 + _exception_count = 0 + + def __init__(self, *args, **kwargs): + self.logger = logging.getLogger(__name__) + for a in kwargs: + super(CBPiSimpleStep, self).__setattr__(a, kwargs.get(a)) + self.id = kwargs.get("id") + self.is_stopped = False + self.is_next = False + self.start = time.time() + + def running(self): + ''' + Method checks if the step should continue running. + The method will return False if the step is requested to stop or the next step should start + + :return: True if the step is running. Otherwise False. + ''' + if self.is_next is True: + return False + + if self.is_stopped is True: + return False + + return True + + async def run(self): + + ''' + This method in running in the background. It invokes the run_cycle method in the configured interval + It checks if a managed variable was modified in the last exection cycle. If yes, the method will persisit the new value of the + managed property + + :return: None + ''' + + while self.running(): + try: + await self.run_cycle() + except Exception as e: + logging.exception("CBPiSimpleStep Error") + self._exception_count = self._exception_count + 1 + if self._exception_count == self._max_exceptions: + self.logger.error("Step Exception limit exceeded. Stopping Step") + self.stop() + + await asyncio.sleep(self._interval) + + if self.is_dirty(): + # Now we have to store the managed props + state = {} + for field in self.managed_fields: + state[field] = self.__getattribute__(field) + #step_controller.model.update_step_state(step_controller.current_step.id, state) + + await self.cbpi.step.model.update_step_state(self.id, state) + + self.reset_dirty() + + @abstractmethod + async def run_cycle(self): + ''' + This method is executed in the defined interval. + That the place to put your step logic. + The method need to be overwritten in the Ccstom step implementaion + + :return: None + ''' + + print("NOTING IMPLEMENTED") + pass + + def next(self): + + ''' + Request to stop the the step + + :return: None + ''' + + self.is_next = True + + def stop(self): + ''' + Request to stop the step + + :return: None + ''' + self.is_stopped = True + + def reset(self): + ''' + Reset the step. This method needs to be overwritten by the custom step implementation + + :return: None + ''' + pass + + def is_dirty(self): + + ''' + Check if a managed variable has a new value + + :return: True if at least one managed variable has a new value assigend. Otherwise False + ''' + return self.__dirty + + def reset_dirty(self): + ''' + Reset the dirty flag + + :return: + ''' + + self.__dirty = False + + def __setattr__(self, name, value): + if name != "_Step__dirty" and name in self.managed_fields: + self.__dirty = True + super(CBPiSimpleStep, self).__setattr__(name, value) + else: + super(CBPiSimpleStep, self).__setattr__(name, value) \ No newline at end of file diff --git a/cbpi/cli.py b/cbpi/cli.py new file mode 100644 index 0000000..4fe12df --- /dev/null +++ b/cbpi/cli.py @@ -0,0 +1,42 @@ +import logging + +from cbpi.craftbeerpi import CraftBeerPi +import os +import pathlib +import shutil + +logging.basicConfig(level=logging.INFO,filename='./logs/app.log', filemode='a', format='%(asctime)s - %(levelname)s - %(name)s - %(message)s') + +def create_plugin_file(): + import os.path + if os.path.exists(os.path.join(".", 'config', "plugin_list.txt")) is False: + srcfile = os.path.join(os.path.dirname(__file__), "config", "plugin_list.txt") + destfile = os.path.join(".", 'config') + shutil.copy(srcfile, destfile) + +def create_config_file(): + import os.path + if os.path.exists(os.path.join(".", 'config', "config.yaml")) is False: + srcfile = os.path.join(os.path.dirname(__file__), "config", "config.yaml") + destfile = os.path.join(".", 'config') + shutil.copy(srcfile, destfile) + +def create_home_folder_structure(): + pathlib.Path(os.path.join(".", 'logs/sensors')).mkdir(parents=True, exist_ok=True) + pathlib.Path(os.path.join(".", 'config')).mkdir(parents=True, exist_ok=True) + + +def main(): + #import sys + #arg1, arg2 = sys.argv[1], sys.argv[2] + + create_home_folder_structure() + create_plugin_file() + create_config_file() + + + cbpi = CraftBeerPi() + cbpi.start() + + + diff --git a/cbpi/config/config.yaml b/cbpi/config/config.yaml new file mode 100644 index 0000000..f05f964 --- /dev/null +++ b/cbpi/config/config.yaml @@ -0,0 +1,11 @@ + +name: CraftBeerPi +version: 4.1 + +#index_url: /myext + +port: 8080 + +username: cbpi +password: 123 + diff --git a/config/create_database.sql b/cbpi/config/create_database.sql similarity index 100% rename from config/create_database.sql rename to cbpi/config/create_database.sql diff --git a/cbpi/config/plugin_list.txt b/cbpi/config/plugin_list.txt new file mode 100644 index 0000000..142c198 --- /dev/null +++ b/cbpi/config/plugin_list.txt @@ -0,0 +1 @@ +cbpi-actor \ No newline at end of file diff --git a/core/controller/__init__.py b/cbpi/controller/__init__.py similarity index 100% rename from core/controller/__init__.py rename to cbpi/controller/__init__.py diff --git a/core/controller/actor_controller.py b/cbpi/controller/actor_controller.py similarity index 97% rename from core/controller/actor_controller.py rename to cbpi/controller/actor_controller.py index 6f80755..b138363 100644 --- a/core/controller/actor_controller.py +++ b/cbpi/controller/actor_controller.py @@ -1,11 +1,11 @@ import logging from asyncio import Future -from cbpi_api import * +from cbpi.api import * from voluptuous import Schema -from core.controller.crud_controller import CRUDController -from core.database.model import ActorModel +from cbpi.controller.crud_controller import CRUDController +from cbpi.database.model import ActorModel class ActorController(CRUDController): diff --git a/core/controller/config_controller.py b/cbpi/controller/config_controller.py similarity index 87% rename from core/controller/config_controller.py rename to cbpi/controller/config_controller.py index f245b18..224bc90 100644 --- a/core/controller/config_controller.py +++ b/cbpi/controller/config_controller.py @@ -1,10 +1,9 @@ import logging import os -from cbpi_api.config import ConfigType - -from core.database.model import ConfigModel -from utils import load_config +from cbpi.api.config import ConfigType +from cbpi.database.model import ConfigModel +from cbpi.utils import load_config class ConfigController(): @@ -21,7 +20,8 @@ class ConfigController(): async def init(self): this_directory = os.path.dirname(__file__) - self.static = load_config(os.path.join(this_directory, '../../config/config.yaml')) + + self.static = load_config("./config/config.yaml") items = await self.model.get_all() for key, value in items.items(): self.cache[value.name] = value diff --git a/core/controller/crud_controller.py b/cbpi/controller/crud_controller.py similarity index 96% rename from core/controller/crud_controller.py rename to cbpi/controller/crud_controller.py index 5f41ef8..506bead 100644 --- a/core/controller/crud_controller.py +++ b/cbpi/controller/crud_controller.py @@ -1,7 +1,7 @@ import pprint from abc import ABCMeta -from cbpi_api.exceptions import CBPiException +from cbpi.api import * class CRUDController(metaclass=ABCMeta): diff --git a/core/controller/dashboard_controller.py b/cbpi/controller/dashboard_controller.py similarity index 86% rename from core/controller/dashboard_controller.py rename to cbpi/controller/dashboard_controller.py index 98d823f..b4f9082 100644 --- a/core/controller/dashboard_controller.py +++ b/cbpi/controller/dashboard_controller.py @@ -2,8 +2,8 @@ import logging from voluptuous import Schema, MultipleInvalid -from core.controller.crud_controller import CRUDController -from core.database.model import DashboardModel, DashboardContentModel +from cbpi.controller.crud_controller import CRUDController +from cbpi.database.model import DashboardModel, DashboardContentModel class DashboardController(CRUDController): diff --git a/core/controller/job_controller.py b/cbpi/controller/job_controller.py similarity index 96% rename from core/controller/job_controller.py rename to cbpi/controller/job_controller.py index e6e0e5f..9e58fb8 100644 --- a/core/controller/job_controller.py +++ b/cbpi/controller/job_controller.py @@ -1,7 +1,7 @@ import asyncio import logging -from job.aiohttp import setup, get_scheduler_from_app +from cbpi.job.aiohttp import setup, get_scheduler_from_app logger = logging.getLogger(__name__) class JobController(object): diff --git a/core/controller/kettle_controller.py b/cbpi/controller/kettle_controller.py similarity index 95% rename from core/controller/kettle_controller.py rename to cbpi/controller/kettle_controller.py index 3b48f8d..592f517 100644 --- a/core/controller/kettle_controller.py +++ b/cbpi/controller/kettle_controller.py @@ -1,13 +1,8 @@ import re - - -from cbpi_api import * -from cbpi_api.exceptions import KettleException, ActorException, SensorException - -from core.controller.crud_controller import CRUDController -from core.database.model import KettleModel - -from core.job.aiohttp import get_scheduler_from_app +from cbpi.api import * +from cbpi.controller.crud_controller import CRUDController +from cbpi.database.model import KettleModel +from cbpi.job.aiohttp import get_scheduler_from_app class KettleController(CRUDController): diff --git a/core/controller/notification_controller.py b/cbpi/controller/notification_controller.py similarity index 94% rename from core/controller/notification_controller.py rename to cbpi/controller/notification_controller.py index 3e12bff..16577d9 100644 --- a/core/controller/notification_controller.py +++ b/cbpi/controller/notification_controller.py @@ -1,4 +1,4 @@ -from cbpi_api import * +from cbpi.api import * class NotificationController(object): diff --git a/core/controller/plugin_controller.py b/cbpi/controller/plugin_controller.py similarity index 89% rename from core/controller/plugin_controller.py rename to cbpi/controller/plugin_controller.py index 6c815fb..4919d49 100644 --- a/core/controller/plugin_controller.py +++ b/cbpi/controller/plugin_controller.py @@ -5,9 +5,9 @@ from importlib import import_module import aiohttp import yaml from aiohttp import web -from cbpi_api import * +from cbpi.api import * -from core.utils.utils import load_config, json_dumps +from cbpi.utils.utils import load_config, json_dumps logger = logging.getLogger(__name__) @@ -33,17 +33,20 @@ class PluginController(): def load_plugins(self): - for filename in os.listdir("./core/extension"): + this_directory = os.path.dirname(__file__) - if os.path.isdir("./core/extension/" + filename) is False or filename == "__pycache__": + for filename in os.listdir(os.path.join(this_directory, "../extension")): + + if os.path.isdir(os.path.join(this_directory, "../extension/") + filename) is False or filename == "__pycache__": continue try: logger.info("Trying to load plugin %s" % filename) - data = load_config("./core/extension/%s/config.yaml" % filename) + + data = load_config(os.path.join(this_directory, "../extension/%s/config.yaml" % filename)) if(data.get("version") == 4): - self.modules[filename] = import_module("core.extension.%s" % (filename)) + self.modules[filename] = import_module("cbpi.extension.%s" % (filename)) self.modules[filename].setup(self.cbpi) logger.info("Plugin %s loaded successful" % filename) @@ -57,8 +60,8 @@ class PluginController(): def load_plugins_from_evn(self): plugins = [] - - with open('./config/plugin_list.txt') as f: + this_directory = os.path.dirname(__file__) + with open(os.path.join(this_directory, "../config/plugin_list.txt")) as f: plugins = f.read().splitlines() plugins = list(set(plugins)) diff --git a/core/controller/sensor_controller.py b/cbpi/controller/sensor_controller.py similarity index 89% rename from core/controller/sensor_controller.py rename to cbpi/controller/sensor_controller.py index fb3f19c..b2fe700 100644 --- a/core/controller/sensor_controller.py +++ b/cbpi/controller/sensor_controller.py @@ -1,12 +1,9 @@ -import json + import logging +from cbpi.controller.crud_controller import CRUDController +from cbpi.database.model import SensorModel +from cbpi.job.aiohttp import get_scheduler_from_app -from cbpi_api import request_mapping - -from core.controller.crud_controller import CRUDController -from core.database.model import SensorModel -from core.job.aiohttp import get_scheduler_from_app -from core.utils.encoder import ComplexEncoder class SensorController(CRUDController): diff --git a/core/controller/step_controller.py b/cbpi/controller/step_controller.py similarity index 97% rename from core/controller/step_controller.py rename to cbpi/controller/step_controller.py index 08809f3..703a73f 100644 --- a/core/controller/step_controller.py +++ b/cbpi/controller/step_controller.py @@ -1,11 +1,9 @@ -import asyncio import logging import time -from cbpi_api import * - -from core.controller.crud_controller import CRUDController -from core.database.model import StepModel +from cbpi.api import * +from cbpi.controller.crud_controller import CRUDController +from cbpi.database.model import StepModel class StepController(CRUDController): diff --git a/core/controller/system_controller.py b/cbpi/controller/system_controller.py similarity index 93% rename from core/controller/system_controller.py rename to cbpi/controller/system_controller.py index aec1a53..47a0814 100644 --- a/core/controller/system_controller.py +++ b/cbpi/controller/system_controller.py @@ -2,9 +2,9 @@ import datetime from aiohttp import web from aiojobs.aiohttp import get_scheduler_from_app -from cbpi_api import * +from cbpi.api import * -from utils import json_dumps +from cbpi.utils import json_dumps class SystemController(): diff --git a/core/craftbeerpi.py b/cbpi/craftbeerpi.py similarity index 84% rename from core/craftbeerpi.py rename to cbpi/craftbeerpi.py index e8dde1d..4af48b3 100644 --- a/core/craftbeerpi.py +++ b/cbpi/craftbeerpi.py @@ -1,5 +1,4 @@ import logging -import os from os import urandom from aiohttp import web @@ -7,33 +6,36 @@ from aiohttp_auth import auth from aiohttp_session import session_middleware from aiohttp_session.cookie_storage import EncryptedCookieStorage from aiohttp_swagger import setup_swagger -from cbpi_api.exceptions import CBPiException +from cbpi.api.exceptions import CBPiException from voluptuous import MultipleInvalid -from controller.dashboard_controller import DashboardController -from controller.job_controller import JobController -from core.controller.actor_controller import ActorController -from core.controller.config_controller import ConfigController -from core.controller.kettle_controller import KettleController -from core.controller.notification_controller import NotificationController -from core.controller.plugin_controller import PluginController -from core.controller.sensor_controller import SensorController -from core.controller.step_controller import StepController -from core.controller.system_controller import SystemController -from core.database.model import DBModel -from core.eventbus import CBPiEventBus -from core.http_endpoints.http_login import Login -from core.utils import * -from core.websocket import CBPiWebSocket -from http_endpoints.http_actor import ActorHttpEndpoints -from http_endpoints.http_config import ConfigHttpEndpoints -from http_endpoints.http_dashboard import DashBoardHttpEndpoints -from http_endpoints.http_kettle import KettleHttpEndpoints -from http_endpoints.http_sensor import SensorHttpEndpoints -from http_endpoints.http_step import StepHttpEndpoints +from cbpi.controller.dashboard_controller import DashboardController +from cbpi.controller.job_controller import JobController +from cbpi.controller.actor_controller import ActorController +from cbpi.controller.config_controller import ConfigController +from cbpi.controller.kettle_controller import KettleController +from cbpi.controller.notification_controller import NotificationController +from cbpi.controller.plugin_controller import PluginController +from cbpi.controller.sensor_controller import SensorController +from cbpi.controller.step_controller import StepController +from cbpi.controller.system_controller import SystemController +from cbpi.database.model import DBModel +from cbpi.eventbus import CBPiEventBus +from cbpi.http_endpoints.http_login import Login +from cbpi.utils import * +from cbpi.websocket import CBPiWebSocket +from cbpi.http_endpoints.http_actor import ActorHttpEndpoints +from cbpi.http_endpoints.http_config import ConfigHttpEndpoints +from cbpi.http_endpoints.http_dashboard import DashBoardHttpEndpoints +from cbpi.http_endpoints.http_kettle import KettleHttpEndpoints +from cbpi.http_endpoints.http_sensor import SensorHttpEndpoints +from cbpi.http_endpoints.http_step import StepHttpEndpoints + logger = logging.getLogger(__name__) -logging.basicConfig(level=logging.INFO) + + + @web.middleware async def error_middleware(request, handler): @@ -56,7 +58,9 @@ async def error_middleware(request, handler): class CraftBeerPi(): def __init__(self): - self.static_config = load_config(os.path.join(os.path.dirname(__file__), '../config/config.yaml')) + + + self.static_config = load_config("./config/config.yaml") self.database_file = "./craftbeerpi.db" logger.info("Init CraftBeerPI") diff --git a/core/database/__init__.py b/cbpi/database/__init__.py similarity index 100% rename from core/database/__init__.py rename to cbpi/database/__init__.py diff --git a/core/database/model.py b/cbpi/database/model.py similarity index 96% rename from core/database/model.py rename to cbpi/database/model.py index 8b5cee2..5c03512 100644 --- a/core/database/model.py +++ b/cbpi/database/model.py @@ -1,10 +1,9 @@ import json import aiosqlite -from cbpi_api.exceptions import CBPiException -from voluptuous import Schema, MultipleInvalid -from core.database.orm_framework import DBModel + +from cbpi.database.orm_framework import DBModel DATABASE_FILE = "./craftbeerpi.db" diff --git a/core/database/orm_framework.py b/cbpi/database/orm_framework.py similarity index 97% rename from core/database/orm_framework.py rename to cbpi/database/orm_framework.py index 3cbf08e..3d52185 100644 --- a/core/database/orm_framework.py +++ b/cbpi/database/orm_framework.py @@ -2,7 +2,7 @@ import json import aiosqlite import os -from cbpi_api.exceptions import CBPiException +from cbpi.api import * from voluptuous import MultipleInvalid, Schema DATABASE_FILE = "./craftbeerpi.db" @@ -38,7 +38,7 @@ class DBModel(object): async with aiosqlite.connect(DATABASE_FILE) as db: assert isinstance(db, aiosqlite.Connection) this_directory = os.path.dirname(__file__) - qry = open(os.path.join(this_directory, '../../config/create_database.sql'), 'r').read() + qry = open(os.path.join(this_directory, "../config/create_database.sql"), 'r').read() cursor = await db.executescript(qry) @classmethod diff --git a/core/eventbus.py b/cbpi/eventbus.py similarity index 97% rename from core/eventbus.py rename to cbpi/eventbus.py index 7f66bec..aa4fd25 100644 --- a/core/eventbus.py +++ b/cbpi/eventbus.py @@ -2,10 +2,12 @@ import asyncio import inspect import logging -from cbpi_api.exceptions import CBPiException +from cbpi.api import * class CBPiEventBus(object): + + class Node(object): __slots__ = '_children', '_content' @@ -22,17 +24,18 @@ class CBPiEventBus(object): self.topic = topic self.supports_future = supports_future - class Result(): + class Result: def __init__(self, result, timeout): self.result = result self.timeout = timeout - class ResultContainer(): + class ResultContainer: def __init__(self, results, timeout=False): self.results = {} self.timeout = timeout + self._jobs = set() for key, value in results.items(): if value.done() is True: self.results[key] = CBPiEventBus.Result(value.result(), True) @@ -108,7 +111,7 @@ class CBPiEventBus(object): def sync_fire(self,topic: str,timeout=1, **kwargs): self.loop.create_task(self.fire(topic=topic, timeout=timeout, **kwargs)) - async def fire(self, topic: str, timeout=1, **kwargs): + async def fire(self, topic: str, timeout=0.5, **kwargs): futures = {} diff --git a/core/extension/__init__.py b/cbpi/extension/__init__.py similarity index 100% rename from core/extension/__init__.py rename to cbpi/extension/__init__.py diff --git a/core/extension/comp/__init__.py b/cbpi/extension/comp/__init__.py similarity index 70% rename from core/extension/comp/__init__.py rename to cbpi/extension/comp/__init__.py index 0045bef..1a473af 100644 --- a/core/extension/comp/__init__.py +++ b/cbpi/extension/comp/__init__.py @@ -1,9 +1,11 @@ +import os + from aiohttp import web -from cbpi_api import * -from core.controller.crud_controller import CRUDController -from core.database.orm_framework import DBModel -from core.http_endpoints.http_api import HttpAPI +from cbpi.api import * +from cbpi.controller.crud_controller import CRUDController +from cbpi.database.orm_framework import DBModel +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints class DummyModel(DBModel): @@ -14,7 +16,7 @@ class DummyModel(DBModel): __table_name__ = "dummy" -class MyComp(CBPiExtension, CRUDController, HttpAPI): +class MyComp(CBPiExtension, CRUDController, HttpCrudEndpoints): model = DummyModel def __init__(self, cbpi): @@ -23,10 +25,12 @@ class MyComp(CBPiExtension, CRUDController, HttpAPI): :param cbpi: ''' + + self.cbpi = cbpi # register component for http, events # In addtion the sub folder static is exposed to access static content via http - self.cbpi.register(self, "/dummy", static="./core/extension/comp/static") + self.cbpi.register(self, "/dummy", static=os.path.join(os.path.dirname(__file__), "static")) @on_event(topic="actor/#") diff --git a/core/extension/comp/config.yaml b/cbpi/extension/comp/config.yaml similarity index 100% rename from core/extension/comp/config.yaml rename to cbpi/extension/comp/config.yaml diff --git a/core/extension/comp/static/index.html b/cbpi/extension/comp/static/index.html similarity index 100% rename from core/extension/comp/static/index.html rename to cbpi/extension/comp/static/index.html diff --git a/core/extension/comp/static/index2.html b/cbpi/extension/comp/static/index2.html similarity index 100% rename from core/extension/comp/static/index2.html rename to cbpi/extension/comp/static/index2.html diff --git a/core/extension/dummyactor/__init__.py b/cbpi/extension/dummyactor/__init__.py similarity index 97% rename from core/extension/dummyactor/__init__.py rename to cbpi/extension/dummyactor/__init__.py index f21060a..a8a890c 100644 --- a/core/extension/dummyactor/__init__.py +++ b/cbpi/extension/dummyactor/__init__.py @@ -1,8 +1,8 @@ import logging from unittest.mock import MagicMock, patch -from cbpi_api import * -from cbpi_api.exceptions import CBPiException +from cbpi.api import * + logger = logging.getLogger(__name__) diff --git a/core/extension/dummyactor/config.yaml b/cbpi/extension/dummyactor/config.yaml similarity index 100% rename from core/extension/dummyactor/config.yaml rename to cbpi/extension/dummyactor/config.yaml diff --git a/core/extension/dummylogic/__init__.py b/cbpi/extension/dummylogic/__init__.py similarity index 98% rename from core/extension/dummylogic/__init__.py rename to cbpi/extension/dummylogic/__init__.py index 2f024b1..3788526 100644 --- a/core/extension/dummylogic/__init__.py +++ b/cbpi/extension/dummylogic/__init__.py @@ -1,6 +1,6 @@ import asyncio -from cbpi_api import * +from cbpi.api import * class CustomLogic(CBPiKettleLogic): diff --git a/core/extension/dummylogic/config.yaml b/cbpi/extension/dummylogic/config.yaml similarity index 100% rename from core/extension/dummylogic/config.yaml rename to cbpi/extension/dummylogic/config.yaml diff --git a/core/extension/dummysensor/__init__.py b/cbpi/extension/dummysensor/__init__.py similarity index 97% rename from core/extension/dummysensor/__init__.py rename to cbpi/extension/dummysensor/__init__.py index 61b5755..2e3a69f 100644 --- a/core/extension/dummysensor/__init__.py +++ b/cbpi/extension/dummysensor/__init__.py @@ -2,7 +2,7 @@ import asyncio import logging import random -from cbpi_api import * +from cbpi.api import * class CustomSensor(CBPiSensor): diff --git a/core/extension/dummysensor/config.yaml b/cbpi/extension/dummysensor/config.yaml similarity index 100% rename from core/extension/dummysensor/config.yaml rename to cbpi/extension/dummysensor/config.yaml diff --git a/core/extension/dummystep/__init__.py b/cbpi/extension/dummystep/__init__.py similarity index 96% rename from core/extension/dummystep/__init__.py rename to cbpi/extension/dummystep/__init__.py index e4921f4..670934e 100644 --- a/core/extension/dummystep/__init__.py +++ b/cbpi/extension/dummystep/__init__.py @@ -1,6 +1,6 @@ import asyncio -from cbpi_api import * +from cbpi.api import * class CustomStepCBPi(CBPiSimpleStep): diff --git a/core/extension/dummystep/config.yaml b/cbpi/extension/dummystep/config.yaml similarity index 100% rename from core/extension/dummystep/config.yaml rename to cbpi/extension/dummystep/config.yaml diff --git a/core/http_endpoints/__init__.py b/cbpi/http_endpoints/__init__.py similarity index 100% rename from core/http_endpoints/__init__.py rename to cbpi/http_endpoints/__init__.py diff --git a/core/http_endpoints/http_actor.py b/cbpi/http_endpoints/http_actor.py similarity index 97% rename from core/http_endpoints/http_actor.py rename to cbpi/http_endpoints/http_actor.py index e084365..38b7dd7 100644 --- a/core/http_endpoints/http_actor.py +++ b/cbpi/http_endpoints/http_actor.py @@ -1,8 +1,8 @@ from aiohttp import web -from cbpi_api import request_mapping -from cbpi_api.exceptions import CBPiException +from cbpi.api import * + +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints -from http_endpoints.http_curd_endpoints import HttpCrudEndpoints auth = False class ActorHttpEndpoints(HttpCrudEndpoints): diff --git a/core/http_endpoints/http_config.py b/cbpi/http_endpoints/http_config.py similarity index 91% rename from core/http_endpoints/http_config.py rename to cbpi/http_endpoints/http_config.py index 2c72c92..b6a2156 100644 --- a/core/http_endpoints/http_config.py +++ b/cbpi/http_endpoints/http_config.py @@ -1,9 +1,8 @@ from aiohttp import web -from cbpi_api import request_mapping -from cbpi_api.exceptions import CBPiException +from cbpi.api import * -from http_endpoints.http_curd_endpoints import HttpCrudEndpoints -from utils import json_dumps +from cbpi.utils import json_dumps +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints class ConfigHttpEndpoints(HttpCrudEndpoints): diff --git a/core/http_endpoints/http_curd_endpoints.py b/cbpi/http_endpoints/http_curd_endpoints.py similarity index 96% rename from core/http_endpoints/http_curd_endpoints.py rename to cbpi/http_endpoints/http_curd_endpoints.py index 83156e0..c918c1d 100644 --- a/core/http_endpoints/http_curd_endpoints.py +++ b/cbpi/http_endpoints/http_curd_endpoints.py @@ -1,9 +1,9 @@ import logging from aiohttp import web -from cbpi_api import * +from cbpi.api import * -from core.utils.utils import json_dumps +from cbpi.utils.utils import json_dumps class HttpCrudEndpoints(): diff --git a/core/http_endpoints/http_dashboard.py b/cbpi/http_endpoints/http_dashboard.py similarity index 97% rename from core/http_endpoints/http_dashboard.py rename to cbpi/http_endpoints/http_dashboard.py index 1af3c15..fe6e94f 100644 --- a/core/http_endpoints/http_dashboard.py +++ b/cbpi/http_endpoints/http_dashboard.py @@ -1,10 +1,9 @@ from aiohttp import web -from cbpi_api import request_mapping +from cbpi.api import * from voluptuous import Schema -from database.model import DashboardContentModel -from http_endpoints.http_curd_endpoints import HttpCrudEndpoints -from utils import json_dumps +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints +from cbpi.utils import json_dumps class DashBoardHttpEndpoints(HttpCrudEndpoints): diff --git a/core/http_endpoints/http_kettle.py b/cbpi/http_endpoints/http_kettle.py similarity index 95% rename from core/http_endpoints/http_kettle.py rename to cbpi/http_endpoints/http_kettle.py index 263ef2b..671111d 100644 --- a/core/http_endpoints/http_kettle.py +++ b/cbpi/http_endpoints/http_kettle.py @@ -1,8 +1,8 @@ from aiohttp import web -from cbpi_api import request_mapping +from cbpi.api import * -from http_endpoints.http_curd_endpoints import HttpCrudEndpoints +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints auth = False diff --git a/core/http_endpoints/http_login.py b/cbpi/http_endpoints/http_login.py similarity index 97% rename from core/http_endpoints/http_login.py rename to cbpi/http_endpoints/http_login.py index 3151504..7be98cd 100644 --- a/core/http_endpoints/http_login.py +++ b/cbpi/http_endpoints/http_login.py @@ -1,7 +1,7 @@ from aiohttp import web from aiohttp_auth import auth -from cbpi_api import * +from cbpi.api import * class Login(): diff --git a/core/http_endpoints/http_sensor.py b/cbpi/http_endpoints/http_sensor.py similarity index 95% rename from core/http_endpoints/http_sensor.py rename to cbpi/http_endpoints/http_sensor.py index f503fab..dddd06a 100644 --- a/core/http_endpoints/http_sensor.py +++ b/cbpi/http_endpoints/http_sensor.py @@ -1,8 +1,6 @@ -from aiohttp import web -from cbpi_api import request_mapping -from cbpi_api.exceptions import CBPiException +from cbpi.api import request_mapping -from http_endpoints.http_curd_endpoints import HttpCrudEndpoints +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints class SensorHttpEndpoints(HttpCrudEndpoints): diff --git a/core/http_endpoints/http_step.py b/cbpi/http_endpoints/http_step.py similarity index 97% rename from core/http_endpoints/http_step.py rename to cbpi/http_endpoints/http_step.py index 1eb2e40..2d0d86c 100644 --- a/core/http_endpoints/http_step.py +++ b/cbpi/http_endpoints/http_step.py @@ -1,8 +1,8 @@ from aiohttp import web -from cbpi_api import request_mapping -from cbpi_api.exceptions import CBPiException +from cbpi.api import * -from http_endpoints.http_curd_endpoints import HttpCrudEndpoints + +from cbpi.http_endpoints.http_curd_endpoints import HttpCrudEndpoints class StepHttpEndpoints(HttpCrudEndpoints): diff --git a/core/job/__init__.py b/cbpi/job/__init__.py similarity index 100% rename from core/job/__init__.py rename to cbpi/job/__init__.py diff --git a/core/job/_job.py b/cbpi/job/_job.py similarity index 100% rename from core/job/_job.py rename to cbpi/job/_job.py diff --git a/core/job/_scheduler.py b/cbpi/job/_scheduler.py similarity index 100% rename from core/job/_scheduler.py rename to cbpi/job/_scheduler.py diff --git a/core/job/aiohttp.py b/cbpi/job/aiohttp.py similarity index 100% rename from core/job/aiohttp.py rename to cbpi/job/aiohttp.py diff --git a/core/mqtt/__init__.py b/cbpi/mqtt/__init__.py similarity index 100% rename from core/mqtt/__init__.py rename to cbpi/mqtt/__init__.py diff --git a/core/mqtt/mqtt.py b/cbpi/mqtt/mqtt.py similarity index 98% rename from core/mqtt/mqtt.py rename to cbpi/mqtt/mqtt.py index f17bc6a..303dc03 100644 --- a/core/mqtt/mqtt.py +++ b/cbpi/mqtt/mqtt.py @@ -1,5 +1,5 @@ from aiojobs.aiohttp import get_scheduler_from_app -from core.mqtt_matcher import MQTTMatcher +from cbpi.mqtt_matcher import MQTTMatcher from hbmqtt.broker import Broker from hbmqtt.client import MQTTClient from hbmqtt.mqtt.constants import QOS_1, QOS_0 diff --git a/core/mqtt/mqtt_matcher.py b/cbpi/mqtt/mqtt_matcher.py similarity index 100% rename from core/mqtt/mqtt_matcher.py rename to cbpi/mqtt/mqtt_matcher.py diff --git a/cbpi/utils/__init__.py b/cbpi/utils/__init__.py new file mode 100644 index 0000000..1bc153a --- /dev/null +++ b/cbpi/utils/__init__.py @@ -0,0 +1 @@ +from cbpi.utils.utils import * diff --git a/core/utils/encoder.py b/cbpi/utils/encoder.py similarity index 90% rename from core/utils/encoder.py rename to cbpi/utils/encoder.py index 49fee31..1c4dfa2 100644 --- a/core/utils/encoder.py +++ b/cbpi/utils/encoder.py @@ -4,7 +4,7 @@ class ComplexEncoder(JSONEncoder): def default(self, obj): - from core.database.orm_framework import DBModel + from cbpi.database.orm_framework import DBModel try: if isinstance(obj, DBModel): diff --git a/core/utils/utils.py b/cbpi/utils/utils.py similarity index 86% rename from core/utils/utils.py rename to cbpi/utils/utils.py index 9d824df..e4c34a4 100644 --- a/core/utils/utils.py +++ b/cbpi/utils/utils.py @@ -1,4 +1,4 @@ -from core.utils.encoder import ComplexEncoder +from cbpi.utils.encoder import ComplexEncoder __all__ = ['load_config',"json_dumps"] diff --git a/core/websocket.py b/cbpi/websocket.py similarity index 95% rename from core/websocket.py rename to cbpi/websocket.py index bccea10..f3e41fe 100644 --- a/core/websocket.py +++ b/cbpi/websocket.py @@ -4,10 +4,10 @@ from collections import defaultdict import aiohttp from aiohttp import web -from cbpi_api import * +from cbpi.api import * from voluptuous import Schema -from utils import json_dumps +from cbpi.utils import json_dumps class CBPiWebSocket: @@ -22,7 +22,7 @@ class CBPiWebSocket: @on_event(topic="#") async def listen(self, topic, **kwargs): data = dict(topic=topic, data=dict(**kwargs)) - self.logger.info("PUSH %s " % data) + self.logger.debug("PUSH %s " % data) self.send(data) def send(self, data): diff --git a/config/plugin_list.txt b/config/plugin_list.txt index c824f34..142c198 100644 --- a/config/plugin_list.txt +++ b/config/plugin_list.txt @@ -1,3 +1 @@ -cbpi-actor -cbpi-actor cbpi-actor \ No newline at end of file diff --git a/core/utils/__init__.py b/core/utils/__init__.py deleted file mode 100644 index 224962f..0000000 --- a/core/utils/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from core.utils.utils import * diff --git a/craftbeerpi.db b/craftbeerpi.db index c153a98..41f81ff 100644 Binary files a/craftbeerpi.db and b/craftbeerpi.db differ diff --git a/logs/sensors/sensor_1.log b/logs/sensors/sensor_1.log deleted file mode 100644 index bb1888d..0000000 --- a/logs/sensors/sensor_1.log +++ /dev/null @@ -1,34 +0,0 @@ -2019-01-04 00:44:35,10 -2019-01-04 00:44:40,10 -2019-01-04 00:44:45,10 -2019-01-04 00:44:50,10 -2019-01-04 00:44:55,10 -2019-01-04 00:45:00,10 -2019-01-04 00:45:05,10 -2019-01-04 00:45:10,10 -2019-01-04 00:45:15,10 -2019-01-04 00:45:20,10 -2019-01-04 00:45:25,10 -2019-01-04 00:45:30,10 -2019-01-04 00:45:35,10 -2019-01-04 00:45:40,10 -2019-01-04 00:45:45,10 -2019-01-04 00:45:50,10 -2019-01-04 00:45:55,10 -2019-01-04 00:46:00,10 -2019-01-04 00:46:05,10 -2019-01-04 00:46:10,10 -2019-01-04 00:46:15,10 -2019-01-04 00:46:20,10 -2019-01-04 00:46:31,10 -2019-01-04 00:46:36,10 -2019-01-04 00:46:41,10 -2019-01-04 00:46:46,10 -2019-01-04 00:46:51,10 -2019-01-04 00:46:56,10 -2019-01-04 00:47:01,10 -2019-01-04 00:47:06,10 -2019-01-04 00:47:11,10 -2019-01-04 00:47:16,10 -2019-01-04 00:47:21,10 -2019-01-04 00:47:26,10 diff --git a/logs/sensors/sensor_1.log.1 b/logs/sensors/sensor_1.log.1 deleted file mode 100644 index 9b83c3e..0000000 --- a/logs/sensors/sensor_1.log.1 +++ /dev/null @@ -1,86 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 -2019-01-04 00:19:48,10 -2019-01-04 00:19:53,10 -2019-01-04 00:20:04,10 -2019-01-04 00:20:09,10 -2019-01-04 00:20:14,10 -2019-01-04 00:20:19,10 -2019-01-04 00:20:24,10 -2019-01-04 00:20:29,10 -2019-01-04 00:20:34,10 -2019-01-04 00:20:39,10 -2019-01-04 00:20:44,10 -2019-01-04 00:20:49,10 -2019-01-04 00:20:54,10 -2019-01-04 00:20:59,10 -2019-01-04 00:38:43,10 -2019-01-04 00:38:48,10 -2019-01-04 00:38:53,10 -2019-01-04 00:38:58,10 -2019-01-04 00:39:03,10 -2019-01-04 00:39:08,10 -2019-01-04 00:39:13,10 -2019-01-04 00:39:18,10 -2019-01-04 00:39:23,10 -2019-01-04 00:39:28,10 -2019-01-04 00:39:33,10 -2019-01-04 00:39:38,10 -2019-01-04 00:39:45,10 -2019-01-04 00:39:54,10 -2019-01-04 00:39:59,10 -2019-01-04 00:40:04,10 -2019-01-04 00:40:09,10 -2019-01-04 00:40:14,10 -2019-01-04 00:40:21,10 -2019-01-04 00:40:31,10 -2019-01-04 00:40:36,10 -2019-01-04 00:40:41,10 -2019-01-04 00:40:46,10 -2019-01-04 00:40:51,10 -2019-01-04 00:40:56,10 -2019-01-04 00:41:01,10 -2019-01-04 00:41:06,10 -2019-01-04 00:41:11,10 -2019-01-04 00:41:16,10 -2019-01-04 00:41:21,10 -2019-01-04 00:41:26,10 -2019-01-04 00:41:31,10 -2019-01-04 00:41:36,10 -2019-01-04 00:41:41,10 -2019-01-04 00:41:46,10 -2019-01-04 00:41:51,10 -2019-01-04 00:41:56,10 -2019-01-04 00:42:01,10 -2019-01-04 00:42:06,10 -2019-01-04 00:42:11,10 -2019-01-04 00:42:16,10 -2019-01-04 00:42:21,10 -2019-01-04 00:42:26,10 -2019-01-04 00:42:31,10 -2019-01-04 00:42:36,10 -2019-01-04 00:42:41,10 -2019-01-04 00:42:46,10 -2019-01-04 00:42:51,10 -2019-01-04 00:42:56,10 -2019-01-04 00:43:05,10 -2019-01-04 00:43:10,10 -2019-01-04 00:43:15,10 -2019-01-04 00:43:20,10 -2019-01-04 00:43:25,10 -2019-01-04 00:43:30,10 -2019-01-04 00:43:35,10 -2019-01-04 00:43:40,10 -2019-01-04 00:43:45,10 -2019-01-04 00:43:50,10 -2019-01-04 00:43:55,10 -2019-01-04 00:44:00,10 -2019-01-04 00:44:05,10 -2019-01-04 00:44:10,10 -2019-01-04 00:44:15,10 -2019-01-04 00:44:20,10 -2019-01-04 00:44:25,10 -2019-01-04 00:44:30,10 diff --git a/logs/sensors/sensor_1.log.10 b/logs/sensors/sensor_1.log.10 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.10 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.2 b/logs/sensors/sensor_1.log.2 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.2 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.3 b/logs/sensors/sensor_1.log.3 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.3 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.4 b/logs/sensors/sensor_1.log.4 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.4 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.5 b/logs/sensors/sensor_1.log.5 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.5 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.6 b/logs/sensors/sensor_1.log.6 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.6 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.7 b/logs/sensors/sensor_1.log.7 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.7 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.8 b/logs/sensors/sensor_1.log.8 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.8 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_1.log.9 b/logs/sensors/sensor_1.log.9 deleted file mode 100644 index 5dfb63a..0000000 --- a/logs/sensors/sensor_1.log.9 +++ /dev/null @@ -1,5 +0,0 @@ -2019-01-04 00:19:10,10 -2019-01-04 00:19:15,10 -2019-01-04 00:19:20,10 -2019-01-04 00:19:25,10 -2019-01-04 00:19:30,10 diff --git a/logs/sensors/sensor_2.log b/logs/sensors/sensor_2.log deleted file mode 100644 index ce17672..0000000 --- a/logs/sensors/sensor_2.log +++ /dev/null @@ -1,23 +0,0 @@ -2019-01-02 18:49:55,10 -2019-01-02 18:49:56,10 -2019-01-02 18:49:57,10 -2019-01-02 18:51:25,10 -2019-01-02 18:51:26,10 -2019-01-02 18:51:27,10 -2019-01-02 18:51:28,10 -2019-01-02 18:51:40,10 -2019-01-02 18:51:41,10 -2019-01-02 18:51:42,10 -2019-01-02 18:51:43,10 -2019-01-02 18:51:49,10 -2019-01-02 18:51:50,10 -2019-01-02 18:51:51,10 -2019-01-02 18:51:52,10 -2019-01-02 18:53:09,10 -2019-01-02 18:53:10,10 -2019-01-02 18:53:11,10 -2019-01-02 18:53:12,10 -2019-01-02 19:03:29,10 -2019-01-02 19:03:30,10 -2019-01-02 19:03:31,10 -2019-01-02 19:03:32,10 diff --git a/logs/sensors/sensor_2.log.1 b/logs/sensors/sensor_2.log.1 deleted file mode 100644 index 369770e..0000000 --- a/logs/sensors/sensor_2.log.1 +++ /dev/null @@ -1,86 +0,0 @@ -2019-01-02 17:05:13,10 -2019-01-02 17:05:14,10 -2019-01-02 17:05:15,10 -2019-01-02 18:02:23,10 -2019-01-02 18:02:24,10 -2019-01-02 18:02:25,10 -2019-01-02 18:02:26,10 -2019-01-02 18:21:31,10 -2019-01-02 18:21:32,10 -2019-01-02 18:21:33,10 -2019-01-02 18:21:34,10 -2019-01-02 18:21:47,10 -2019-01-02 18:21:48,10 -2019-01-02 18:21:49,10 -2019-01-02 18:21:50,10 -2019-01-02 18:21:51,10 -2019-01-02 18:29:16,10 -2019-01-02 18:29:17,10 -2019-01-02 18:29:18,10 -2019-01-02 18:29:19,10 -2019-01-02 18:31:37,10 -2019-01-02 18:31:38,10 -2019-01-02 18:31:39,10 -2019-01-02 18:31:40,10 -2019-01-02 18:32:06,10 -2019-01-02 18:32:07,10 -2019-01-02 18:32:08,10 -2019-01-02 18:32:09,10 -2019-01-02 18:32:59,10 -2019-01-02 18:33:00,10 -2019-01-02 18:33:01,10 -2019-01-02 18:33:02,10 -2019-01-02 18:33:33,10 -2019-01-02 18:33:34,10 -2019-01-02 18:33:35,10 -2019-01-02 18:33:36,10 -2019-01-02 18:33:37,10 -2019-01-02 18:34:07,10 -2019-01-02 18:34:08,10 -2019-01-02 18:34:09,10 -2019-01-02 18:34:10,10 -2019-01-02 18:37:59,10 -2019-01-02 18:38:00,10 -2019-01-02 18:38:01,10 -2019-01-02 18:38:02,10 -2019-01-02 18:38:48,10 -2019-01-02 18:38:49,10 -2019-01-02 18:38:50,10 -2019-01-02 18:38:51,10 -2019-01-02 18:38:52,10 -2019-01-02 18:40:45,10 -2019-01-02 18:40:46,10 -2019-01-02 18:40:47,10 -2019-01-02 18:40:48,10 -2019-01-02 18:40:56,10 -2019-01-02 18:40:57,10 -2019-01-02 18:40:58,10 -2019-01-02 18:40:59,10 -2019-01-02 18:41:00,10 -2019-01-02 18:41:50,10 -2019-01-02 18:41:51,10 -2019-01-02 18:41:52,10 -2019-01-02 18:41:53,10 -2019-01-02 18:43:39,10 -2019-01-02 18:43:40,10 -2019-01-02 18:43:41,10 -2019-01-02 18:43:42,10 -2019-01-02 18:44:37,10 -2019-01-02 18:44:38,10 -2019-01-02 18:44:39,10 -2019-01-02 18:44:40,10 -2019-01-02 18:44:41,10 -2019-01-02 18:45:17,10 -2019-01-02 18:45:18,10 -2019-01-02 18:45:19,10 -2019-01-02 18:45:20,10 -2019-01-02 18:47:19,10 -2019-01-02 18:47:20,10 -2019-01-02 18:47:21,10 -2019-01-02 18:47:22,10 -2019-01-02 18:47:23,10 -2019-01-02 18:49:03,10 -2019-01-02 18:49:05,10 -2019-01-02 18:49:06,10 -2019-01-02 18:49:07,10 -2019-01-02 18:49:54,10 diff --git a/logs/sensors/sensor_2.log.2 b/logs/sensors/sensor_2.log.2 deleted file mode 100644 index 2d49672..0000000 --- a/logs/sensors/sensor_2.log.2 +++ /dev/null @@ -1,86 +0,0 @@ -2019-01-02 11:15:04,10 -2019-01-02 11:16:21,10 -2019-01-02 11:16:22,10 -2019-01-02 11:16:23,10 -2019-01-02 11:16:24,10 -2019-01-02 11:16:25,10 -2019-01-02 11:18:51,10 -2019-01-02 11:18:52,10 -2019-01-02 11:18:53,10 -2019-01-02 11:18:54,10 -2019-01-02 16:19:57,10 -2019-01-02 16:19:58,10 -2019-01-02 16:19:59,10 -2019-01-02 16:20:00,10 -2019-01-02 16:20:01,10 -2019-01-02 16:21:08,10 -2019-01-02 16:21:09,10 -2019-01-02 16:21:10,10 -2019-01-02 16:21:11,10 -2019-01-02 16:21:25,10 -2019-01-02 16:21:26,10 -2019-01-02 16:21:27,10 -2019-01-02 16:21:28,10 -2019-01-02 16:22:24,10 -2019-01-02 16:22:25,10 -2019-01-02 16:22:26,10 -2019-01-02 16:22:27,10 -2019-01-02 16:23:42,10 -2019-01-02 16:23:43,10 -2019-01-02 16:23:44,10 -2019-01-02 16:23:45,10 -2019-01-02 16:23:46,10 -2019-01-02 16:24:55,10 -2019-01-02 16:24:56,10 -2019-01-02 16:24:57,10 -2019-01-02 16:24:58,10 -2019-01-02 16:24:59,10 -2019-01-02 16:25:20,10 -2019-01-02 16:25:21,10 -2019-01-02 16:25:22,10 -2019-01-02 16:25:23,10 -2019-01-02 16:25:24,10 -2019-01-02 16:26:25,10 -2019-01-02 16:26:26,10 -2019-01-02 16:26:27,10 -2019-01-02 16:26:28,10 -2019-01-02 16:52:03,10 -2019-01-02 16:52:04,10 -2019-01-02 16:52:05,10 -2019-01-02 16:52:06,10 -2019-01-02 16:52:07,10 -2019-01-02 16:52:47,10 -2019-01-02 16:52:48,10 -2019-01-02 16:52:49,10 -2019-01-02 16:52:50,10 -2019-01-02 16:53:19,10 -2019-01-02 16:53:20,10 -2019-01-02 16:53:22,10 -2019-01-02 16:53:23,10 -2019-01-02 16:53:46,10 -2019-01-02 16:53:47,10 -2019-01-02 16:53:48,10 -2019-01-02 16:53:49,10 -2019-01-02 17:00:57,10 -2019-01-02 17:00:58,10 -2019-01-02 17:00:59,10 -2019-01-02 17:01:00,10 -2019-01-02 17:01:06,10 -2019-01-02 17:01:07,10 -2019-01-02 17:01:08,10 -2019-01-02 17:01:09,10 -2019-01-02 17:02:14,10 -2019-01-02 17:02:15,10 -2019-01-02 17:02:16,10 -2019-01-02 17:02:17,10 -2019-01-02 17:02:18,10 -2019-01-02 17:02:34,10 -2019-01-02 17:02:35,10 -2019-01-02 17:02:36,10 -2019-01-02 17:02:37,10 -2019-01-02 17:02:38,10 -2019-01-02 17:02:48,10 -2019-01-02 17:02:49,10 -2019-01-02 17:02:50,10 -2019-01-02 17:02:51,10 -2019-01-02 17:05:12,10 diff --git a/logs/sensors/sensor_2.log.3 b/logs/sensors/sensor_2.log.3 deleted file mode 100644 index 13633b0..0000000 --- a/logs/sensors/sensor_2.log.3 +++ /dev/null @@ -1,86 +0,0 @@ -2019-01-01 16:29:39,10 -2019-01-01 16:29:40,10 -2019-01-01 16:29:41,10 -2019-01-01 16:29:42,10 -2019-01-01 16:31:21,10 -2019-01-01 16:31:22,10 -2019-01-01 16:31:23,10 -2019-01-01 16:31:24,10 -2019-01-01 16:49:40,10 -2019-01-01 16:49:41,10 -2019-01-01 16:49:42,10 -2019-01-01 16:49:43,10 -2019-01-01 16:51:23,10 -2019-01-01 16:51:24,10 -2019-01-01 16:51:25,10 -2019-01-01 16:51:26,10 -2019-01-02 10:46:44,10 -2019-01-02 10:46:45,10 -2019-01-02 10:46:46,10 -2019-01-02 10:46:47,10 -2019-01-02 10:46:48,10 -2019-01-02 10:48:16,10 -2019-01-02 10:48:17,10 -2019-01-02 10:48:18,10 -2019-01-02 10:48:19,10 -2019-01-02 10:48:41,10 -2019-01-02 10:48:42,10 -2019-01-02 10:48:43,10 -2019-01-02 10:48:44,10 -2019-01-02 10:48:45,10 -2019-01-02 10:49:30,10 -2019-01-02 10:49:31,10 -2019-01-02 10:49:32,10 -2019-01-02 10:49:33,10 -2019-01-02 10:49:51,10 -2019-01-02 10:49:52,10 -2019-01-02 10:49:53,10 -2019-01-02 10:49:54,10 -2019-01-02 10:56:09,10 -2019-01-02 10:56:10,10 -2019-01-02 10:56:11,10 -2019-01-02 10:56:12,10 -2019-01-02 10:56:35,10 -2019-01-02 10:56:36,10 -2019-01-02 10:56:37,10 -2019-01-02 10:56:38,10 -2019-01-02 11:01:55,10 -2019-01-02 11:01:56,10 -2019-01-02 11:01:57,10 -2019-01-02 11:01:58,10 -2019-01-02 11:03:23,10 -2019-01-02 11:03:24,10 -2019-01-02 11:03:25,10 -2019-01-02 11:03:26,10 -2019-01-02 11:04:47,10 -2019-01-02 11:04:48,10 -2019-01-02 11:04:49,10 -2019-01-02 11:04:50,10 -2019-01-02 11:05:22,10 -2019-01-02 11:05:23,10 -2019-01-02 11:05:24,10 -2019-01-02 11:05:25,10 -2019-01-02 11:06:54,10 -2019-01-02 11:06:55,10 -2019-01-02 11:06:56,10 -2019-01-02 11:06:57,10 -2019-01-02 11:08:16,10 -2019-01-02 11:08:17,10 -2019-01-02 11:08:18,10 -2019-01-02 11:08:19,10 -2019-01-02 11:09:04,10 -2019-01-02 11:09:05,10 -2019-01-02 11:09:06,10 -2019-01-02 11:09:07,10 -2019-01-02 11:10:59,10 -2019-01-02 11:11:00,10 -2019-01-02 11:11:01,10 -2019-01-02 11:11:02,10 -2019-01-02 11:11:03,10 -2019-01-02 11:14:02,10 -2019-01-02 11:14:03,10 -2019-01-02 11:14:04,10 -2019-01-02 11:14:05,10 -2019-01-02 11:15:01,10 -2019-01-02 11:15:02,10 -2019-01-02 11:15:03,10 diff --git a/requirements.txt b/requirements.txt index 2528eb1..c019d57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,66 +6,6 @@ aiohttp-session==2.7.0 aiohttp-swagger==1.0.5 aiojobs==0.2.2 aiosqlite==0.7.0 -alabaster==0.7.12 -asn1crypto==0.24.0 -async-timeout==3.0.1 -asynctest==0.12.2 -atomicwrites==1.2.1 -attrs==18.2.0 -Babel==2.6.0 -beautifulsoup4==4.6.3 -bleach==3.0.2 -bs4==0.0.1 -cbpi-api==4.0.1 -CBPiActor1==4.0.3 -certifi==2018.10.15 -cffi==1.11.5 -chardet==3.0.4 -Click==7.0 -coverage==4.5.2 cryptography==2.3.1 -docopt==0.6.2 -docutils==0.14 -gTTS==2.0.1 -gTTS-token==1.1.3 -hbmqtt==0.9.4 -idna==2.7 -idna-ssl==1.1.0 -imagesize==1.1.0 -Jinja2==2.10 -MarkupSafe==1.0 -more-itertools==4.3.0 -multidict==4.4.2 -packaging==18.0 -passlib==1.7.1 -pkginfo==1.4.2 -pluggy==0.7.1 -py==1.7.0 -pycparser==2.19 -pyfiglet==0.7.6 -pygame==1.9.4 -Pygments==2.2.0 -pync==2.0.3 -pyparsing==2.3.0 -pytest==3.8.2 -pytest-aiohttp==0.3.0 -python-dateutil==2.7.5 -pytz==2018.7 -PyYAML==3.13 -readme-renderer==24.0 -requests==2.20.1 -requests-toolbelt==0.8.0 -six==1.11.0 -snowballstemmer==1.2.1 -Sphinx==1.8.2 -sphinx-rtd-theme==0.4.2 -sphinxcontrib-websupport==1.1.0 -ticket-auth==0.1.4 -tqdm==4.28.1 -transitions==0.6.8 -twine==1.12.1 -urllib3==1.24.1 voluptuous==0.11.5 -webencodings==0.5.1 -websockets==6.0 -yarl==1.2.6 +pyfigle==0.7.6 \ No newline at end of file diff --git a/run.py b/run.py index a5a391a..db3291c 100644 --- a/run.py +++ b/run.py @@ -1,4 +1,3 @@ -from core.craftbeerpi import CraftBeerPi +from cbpi.cli import main -cbpi = CraftBeerPi() -cbpi.start() \ No newline at end of file +main() \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..350fdb6 --- /dev/null +++ b/setup.py @@ -0,0 +1,37 @@ +from setuptools import setup, find_packages + +setup(name='cbpi', + version='0.0.1', + description='CraftBeerPi API', + author='Manuel Fritsch', + author_email='manuel@craftbeerpi.com', + url='http://web.craftbeerpi.com', + packages=find_packages(), + include_package_data=True, + package_data={ + # If any package contains *.txt or *.rst files, include them: + '': ['*.txt', '*.rst', '*.yaml'], + 'cbpi': ['*','*.txt', '*.rst', '*.yaml']}, + + install_requires=[ + "aiohttp==3.4.4", + "aiohttp-auth==0.1.1", + "aiohttp-route-decorator==0.1.4", + "aiohttp-security==0.4.0", + "aiohttp-session==2.7.0", + "aiohttp-swagger==1.0.5", + "aiojobs==0.2.2", + "aiosqlite==0.7.0", + "cryptography==2.3.1", + "voluptuous==0.11.5", + "pyfiglet==0.7.6" + ], + dependency_links=[ + 'https://testpypi.python.org/pypi' + ], + entry_points = { + "console_scripts": [ + "cbpi=cbpi.cli:main", + ] + } +) \ No newline at end of file diff --git a/tests/test_actor.py b/tests/test_actor.py index 4114c32..43f03fc 100644 --- a/tests/test_actor.py +++ b/tests/test_actor.py @@ -2,7 +2,7 @@ from unittest import mock from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class ActorTestCase(AioHTTPTestCase): diff --git a/tests/test_config.py b/tests/test_config.py index 1aa793d..331e47b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,9 +2,9 @@ import time import aiosqlite from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from cbpi_api.config import ConfigType +from cbpi.api.config import ConfigType -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class ConfigTestCase(AioHTTPTestCase): diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index b020317..2b657c5 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -1,7 +1,7 @@ import aiohttp from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class DashboardTestCase(AioHTTPTestCase): diff --git a/tests/test_index.py b/tests/test_index.py index 5768081..216a77d 100644 --- a/tests/test_index.py +++ b/tests/test_index.py @@ -1,6 +1,6 @@ from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class IndexTestCase(AioHTTPTestCase): diff --git a/tests/test_kettle.py b/tests/test_kettle.py index 27a93e8..3de97df 100644 --- a/tests/test_kettle.py +++ b/tests/test_kettle.py @@ -1,6 +1,6 @@ import asyncio from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class KettleTestCase(AioHTTPTestCase): diff --git a/tests/test_notification_controller.py b/tests/test_notification_controller.py index 63a94d2..b69bfc0 100644 --- a/tests/test_notification_controller.py +++ b/tests/test_notification_controller.py @@ -1,7 +1,7 @@ import aiohttp from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class NotificationTestCase(AioHTTPTestCase): diff --git a/tests/test_sensor.py b/tests/test_sensor.py index 7b4c2f0..7473469 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,6 +1,6 @@ import asyncio from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class SensorTestCase(AioHTTPTestCase): diff --git a/tests/test_step.py b/tests/test_step.py index a7da19e..77d4811 100644 --- a/tests/test_step.py +++ b/tests/test_step.py @@ -2,7 +2,7 @@ import asyncio from unittest import mock from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class StepTestCase(AioHTTPTestCase): diff --git a/tests/test_system.py b/tests/test_system.py index 8977c88..dd4de41 100644 --- a/tests/test_system.py +++ b/tests/test_system.py @@ -1,6 +1,6 @@ from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class IndexTestCase(AioHTTPTestCase): diff --git a/tests/test_utils.py b/tests/test_utils.py index d5c0262..35b52b7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,6 +1,6 @@ from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi, load_config +from cbpi.craftbeerpi import CraftBeerPi, load_config class UtilsTestCase(AioHTTPTestCase): diff --git a/tests/test_ws.py b/tests/test_ws.py index 14bd154..c0ebce8 100644 --- a/tests/test_ws.py +++ b/tests/test_ws.py @@ -3,7 +3,7 @@ import asyncio import aiohttp from aiohttp.test_utils import AioHTTPTestCase, unittest_run_loop -from core.craftbeerpi import CraftBeerPi +from cbpi.craftbeerpi import CraftBeerPi class WebSocketTestCase(AioHTTPTestCase):