- switched most occurrences of "print" to "logger"pull/147/head
| @@ -0,0 +1,19 @@ | |||||
| version: 1 | |||||
| formatters: | |||||
| simple: | |||||
| format: '%(asctime)s - %(levelname)-8s - %(name)s - %(message)s' | |||||
| handlers: | |||||
| console: | |||||
| class: logging.StreamHandler | |||||
| level: DEBUG | |||||
| formatter: simple | |||||
| stream: ext://sys.stdout | |||||
| file: | |||||
| class : logging.handlers.RotatingFileHandler | |||||
| formatter: simple | |||||
| filename: ./logs/app.log | |||||
| maxBytes: 10000000 | |||||
| backupCount: 3 | |||||
| root: | |||||
| level: DEBUG | |||||
| handlers: [console, file] | |||||
| @@ -1,8 +1,12 @@ | |||||
| import json | import json | ||||
| import logging | |||||
| from flask_classy import FlaskView, route | from flask_classy import FlaskView, route | ||||
| from modules.core.core import cbpi | from modules.core.core import cbpi | ||||
| class ActionView(FlaskView): | class ActionView(FlaskView): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| @route('/<action>', methods=['POST']) | @route('/<action>', methods=['POST']) | ||||
| def action(self, action): | def action(self, action): | ||||
| @@ -15,7 +19,7 @@ class ActionView(FlaskView): | |||||
| 200: | 200: | ||||
| description: action invoked | description: action invoked | ||||
| """ | """ | ||||
| print self.cbpi.cache["actions"] | |||||
| self.logger.info(self.cbpi.cache["actions"]) | |||||
| self.cbpi.cache["actions"][action]["function"](self.cbpi) | self.cbpi.cache["actions"][action]["function"](self.cbpi) | ||||
| return ('',204) | return ('',204) | ||||
| @@ -1,14 +1,17 @@ | |||||
| import logging | |||||
| from modules.core.baseapi import Buzzer | from modules.core.baseapi import Buzzer | ||||
| from modules.core.basetypes import Actor, KettleController, FermenterController | from modules.core.basetypes import Actor, KettleController, FermenterController | ||||
| from modules.core.core import cbpi | from modules.core.core import cbpi | ||||
| @cbpi.addon.actor.type("Dummy Actor") | @cbpi.addon.actor.type("Dummy Actor") | ||||
| class Dummy(Actor): | class Dummy(Actor): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| @cbpi.addon.actor.action("WOHOO") | @cbpi.addon.actor.action("WOHOO") | ||||
| def myaction(self): | def myaction(self): | ||||
| print "HALLO!!!" | |||||
| self.logger.debug("HALLO!!!") | |||||
| def on(self, power=100): | def on(self, power=100): | ||||
| ''' | ''' | ||||
| @@ -16,35 +19,41 @@ class Dummy(Actor): | |||||
| :param power: int value between 0 - 100 | :param power: int value between 0 - 100 | ||||
| :return: | :return: | ||||
| ''' | ''' | ||||
| print "ON" | |||||
| self.logger.info("ON") | |||||
| def off(self): | def off(self): | ||||
| print "OFF" | |||||
| self.logger.info("OFF") | |||||
| @cbpi.addon.kettle.controller() | @cbpi.addon.kettle.controller() | ||||
| class MyController(KettleController): | class MyController(KettleController): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| def run(self): | def run(self): | ||||
| while self.is_running(): | while self.is_running(): | ||||
| print "HALLO" | |||||
| self.logger.debug("HALLO") | |||||
| self.sleep(1) | self.sleep(1) | ||||
| @cbpi.addon.fermenter.controller() | @cbpi.addon.fermenter.controller() | ||||
| class MyController2(FermenterController): | class MyController2(FermenterController): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| def run(self): | def run(self): | ||||
| while self.is_running(): | while self.is_running(): | ||||
| print "HALLO" | |||||
| self.logger.debug("HALLO") | |||||
| self.sleep(1) | self.sleep(1) | ||||
| @cbpi.addon.core.initializer(order=200) | @cbpi.addon.core.initializer(order=200) | ||||
| def init(cbpi): | def init(cbpi): | ||||
| class MyBuzzer(Buzzer): | class MyBuzzer(Buzzer): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| def beep(self): | def beep(self): | ||||
| print "BEEEEEEP" | |||||
| self.logger.info("BEEEEEEP") | |||||
| cbpi.buzzer = MyBuzzer() | cbpi.buzzer = MyBuzzer() | ||||
| @@ -3,10 +3,12 @@ import os | |||||
| from os.path import join | from os.path import join | ||||
| from modules.core.basetypes import Actor, Sensor | |||||
| from modules.core.basetypes import Sensor | |||||
| from modules.core.core import cbpi | from modules.core.core import cbpi | ||||
| from modules.core.proptypes import Property | from modules.core.proptypes import Property | ||||
| import random | |||||
| import logging | |||||
| print "INit SENSOR" | print "INit SENSOR" | ||||
| @cbpi.addon.sensor.type("Dummy Sensor") | @cbpi.addon.sensor.type("Dummy Sensor") | ||||
| class Dummy(Sensor): | class Dummy(Sensor): | ||||
| @@ -14,8 +16,10 @@ class Dummy(Sensor): | |||||
| text = Property.Text(label="Text", required=True, description="This is a parameter", configurable=True) | text = Property.Text(label="Text", required=True, description="This is a parameter", configurable=True) | ||||
| p = Property.Select(label="hallo",options=[1,2,3]) | p = Property.Select(label="hallo",options=[1,2,3]) | ||||
| def init(self): | |||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| def init(self): | |||||
| if self.api.get_config_parameter("unit","C") == "C": | if self.api.get_config_parameter("unit","C") == "C": | ||||
| self.unit = "°C" | self.unit = "°C" | ||||
| else: | else: | ||||
| @@ -23,8 +27,8 @@ class Dummy(Sensor): | |||||
| @cbpi.addon.sensor.action("WOHOO") | @cbpi.addon.sensor.action("WOHOO") | ||||
| def myaction(self): | def myaction(self): | ||||
| print self.text | |||||
| print "SENSOR ACTION HALLO!!!" | |||||
| self.logger.info(self.text) | |||||
| self.logger.debug("SENSOR ACTION HALLO!!!") | |||||
| def execute(self): | def execute(self): | ||||
| while True: | while True: | ||||
| @@ -1,3 +1,5 @@ | |||||
| import logging | |||||
| from modules.core.basetypes import Step | from modules.core.basetypes import Step | ||||
| from modules.core.core import cbpi | from modules.core.core import cbpi | ||||
| from modules.core.proptypes import Property | from modules.core.proptypes import Property | ||||
| @@ -6,20 +8,23 @@ from modules.core.proptypes import Property | |||||
| @cbpi.addon.step.type("Dummy Step") | @cbpi.addon.step.type("Dummy Step") | ||||
| class Dummy(Step): | class Dummy(Step): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| @cbpi.addon.step.action("WOHOO") | @cbpi.addon.step.action("WOHOO") | ||||
| def myaction(self): | def myaction(self): | ||||
| self.stop_timer() | self.stop_timer() | ||||
| self.start_timer(10) | self.start_timer(10) | ||||
| print "HALLO" | |||||
| self.logger.debug("HALLO") | |||||
| text = Property.Text(label="Text", configurable=True, description="WOHOOO") | text = Property.Text(label="Text", configurable=True, description="WOHOOO") | ||||
| time = Property.Text(label="Text", configurable=True, description="WOHOOO") | time = Property.Text(label="Text", configurable=True, description="WOHOOO") | ||||
| def execute(self): | def execute(self): | ||||
| #print self.text | |||||
| self.logger.debug(self.text) | |||||
| pass | pass | ||||
| def reset(self): | def reset(self): | ||||
| print "RESET STEP!!!" | |||||
| self.stop_timer() | |||||
| self.logger.info("RESET STEP!!!") | |||||
| self.stop_timer() | |||||
| @@ -1,3 +1,5 @@ | |||||
| import logging | |||||
| from proptypes import * | from proptypes import * | ||||
| class BaseAPI(object): | class BaseAPI(object): | ||||
| @@ -148,6 +150,8 @@ class CoreAPI(BaseAPI): | |||||
| key = "core" | key = "core" | ||||
| def __init__(self, cbpi): | def __init__(self, cbpi): | ||||
| self.logger = logging.getLogger(__name__) | |||||
| self.cbpi = cbpi | self.cbpi = cbpi | ||||
| self.cbpi.cache["actions"] = {} | self.cbpi.cache["actions"] = {} | ||||
| self.cbpi.cache["init"] = [] | self.cbpi.cache["init"] = [] | ||||
| @@ -160,7 +164,7 @@ class CoreAPI(BaseAPI): | |||||
| self.cbpi.cache["init"] = sorted(self.cbpi.cache["init"], key=lambda k: k['order']) | self.cbpi.cache["init"] = sorted(self.cbpi.cache["init"], key=lambda k: k['order']) | ||||
| for value in self.cbpi.cache.get("init"): | for value in self.cbpi.cache.get("init"): | ||||
| print value | |||||
| self.logger.debug(value) | |||||
| value["function"](self.cbpi) | value["function"](self.cbpi) | ||||
| def job(interval, method): | def job(interval, method): | ||||
| @@ -168,7 +172,7 @@ class CoreAPI(BaseAPI): | |||||
| try: | try: | ||||
| method(self.cbpi) | method(self.cbpi) | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.debug(e) | |||||
| self.cbpi._socketio.sleep(interval) | self.cbpi._socketio.sleep(interval) | ||||
| for value in self.cbpi.cache.get("background"): | for value in self.cbpi.cache.get("background"): | ||||
| @@ -1,3 +1,5 @@ | |||||
| import logging | |||||
| from modules.core.proptypes import Property | from modules.core.proptypes import Property | ||||
| import time | import time | ||||
| @@ -13,6 +15,8 @@ class Base(object): | |||||
| self.__dirty = False | self.__dirty = False | ||||
| class Actor(Base): | class Actor(Base): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| @classmethod | @classmethod | ||||
| def init_global(cls): | def init_global(cls): | ||||
| @@ -26,15 +30,15 @@ class Actor(Base): | |||||
| pass | pass | ||||
| def on(self, power=100): | def on(self, power=100): | ||||
| print "SWITCH ON" | |||||
| self.logger.info("SWITCH ON") | |||||
| pass | pass | ||||
| def off(self): | def off(self): | ||||
| print "SWITCH OFF" | |||||
| self.logger.info("SWITCH OFF") | |||||
| pass | pass | ||||
| def power(self, power): | def power(self, power): | ||||
| print "SET POWER", power | |||||
| self.logger.info("SET POWER TO [%s]", power) | |||||
| pass | pass | ||||
| def state(self): | def state(self): | ||||
| @@ -42,6 +46,8 @@ class Actor(Base): | |||||
| class Sensor(Base): | class Sensor(Base): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| unit = "" | unit = "" | ||||
| @@ -65,7 +71,7 @@ class Sensor(Base): | |||||
| self.cbpi.ws_emit("SENSOR_UPDATE", self.cbpi.cache["sensors"][self.id]) | self.cbpi.ws_emit("SENSOR_UPDATE", self.cbpi.cache["sensors"][self.id]) | ||||
| def execute(self): | def execute(self): | ||||
| print "EXECUTE" | |||||
| self.logger.info("EXECUTE") | |||||
| pass | pass | ||||
| @@ -229,7 +235,6 @@ class Timer(object): | |||||
| class Step(Base, Timer): | class Step(Base, Timer): | ||||
| @classmethod | @classmethod | ||||
| def init_global(cls): | def init_global(cls): | ||||
| pass | pass | ||||
| @@ -251,12 +256,13 @@ class Step(Base, Timer): | |||||
| pass | pass | ||||
| def execute(self): | def execute(self): | ||||
| print "-------------" | |||||
| print "Step Info" | |||||
| print "Kettle ID: %s" % self.kettle_id | |||||
| print "ID: %s" % self.id | |||||
| self.logger.info("-------------") | |||||
| self.logger.info("Step Info") | |||||
| self.logger.info("Kettle ID: %s" % self.kettle_id) | |||||
| self.logger.info("ID: %s" % self.id) | |||||
| def __init__(self, *args, **kwds): | def __init__(self, *args, **kwds): | ||||
| self.logger = logging.getLogger(__name__) | |||||
| for a in kwds: | for a in kwds: | ||||
| super(Step, self).__setattr__(a, kwds.get(a)) | super(Step, self).__setattr__(a, kwds.get(a)) | ||||
| @@ -1,8 +1,10 @@ | |||||
| import json | import json | ||||
| import logging | import logging | ||||
| import logging.config | |||||
| import os | import os | ||||
| import sqlite3 | import sqlite3 | ||||
| import uuid | import uuid | ||||
| import yaml | |||||
| from datetime import datetime | from datetime import datetime | ||||
| from functools import wraps, update_wrapper | from functools import wraps, update_wrapper | ||||
| from importlib import import_module | from importlib import import_module | ||||
| @@ -62,6 +64,8 @@ class ActorCore(object): | |||||
| key = "actor_types" | key = "actor_types" | ||||
| def __init__(self, cbpi): | def __init__(self, cbpi): | ||||
| self.logger = logging.getLogger(__name__) | |||||
| self.cbpi = cbpi | self.cbpi = cbpi | ||||
| self.cbpi.cache["actors"] = {} | self.cbpi.cache["actors"] = {} | ||||
| self.cbpi.cache[self.key] = {} | self.cbpi.cache[self.key] = {} | ||||
| @@ -72,7 +76,7 @@ class ActorCore(object): | |||||
| def init_one(self, id): | def init_one(self, id): | ||||
| try: | try: | ||||
| print "INIT ONE ACTOR", id | |||||
| self.logger.info("INIT ONE ACTOR [%s]", id) | |||||
| actor = self.cbpi.cache["actors"][id] | actor = self.cbpi.cache["actors"][id] | ||||
| clazz = self.cbpi.cache[self.key].get(actor.type)["class"] | clazz = self.cbpi.cache[self.key].get(actor.type)["class"] | ||||
| cfg = actor.config.copy() | cfg = actor.config.copy() | ||||
| @@ -82,8 +86,7 @@ class ActorCore(object): | |||||
| actor.power = 100 | actor.power = 100 | ||||
| self.cbpi.emit("INIT_ACTOR", id=id) | self.cbpi.emit("INIT_ACTOR", id=id) | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.cbpi._app.logger.error(e) | |||||
| self.logger.error(e) | |||||
| def stop_one(self, id): | def stop_one(self, id): | ||||
| self.cbpi.cache["actors"][id]["instance"].stop() | self.cbpi.cache["actors"][id]["instance"].stop() | ||||
| @@ -99,7 +102,7 @@ class ActorCore(object): | |||||
| self.cbpi.emit("SWITCH_ACTOR_ON", id=id, power=power) | self.cbpi.emit("SWITCH_ACTOR_ON", id=id, power=power) | ||||
| return True | return True | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| return False | return False | ||||
| def off(self, id): | def off(self, id): | ||||
| @@ -111,7 +114,7 @@ class ActorCore(object): | |||||
| self.cbpi.emit("SWITCH_ACTOR_OFF", id=id) | self.cbpi.emit("SWITCH_ACTOR_OFF", id=id) | ||||
| return True | return True | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| return False | return False | ||||
| def toggle(self, id): | def toggle(self, id): | ||||
| @@ -129,7 +132,7 @@ class ActorCore(object): | |||||
| self.cbpi.emit("SWITCH_ACTOR_POWER_CHANGE", id=id, power=power) | self.cbpi.emit("SWITCH_ACTOR_POWER_CHANGE", id=id, power=power) | ||||
| return True | return True | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| return False | return False | ||||
| def action(self, id, method): | def action(self, id, method): | ||||
| @@ -147,14 +150,16 @@ class ActorCore(object): | |||||
| job = self.cbpi._socketio.start_background_task(target=toggle, id=id, seconds=seconds) | job = self.cbpi._socketio.start_background_task(target=toggle, id=id, seconds=seconds) | ||||
| def get_state(self, actor_id): | def get_state(self, actor_id): | ||||
| print actor_id | |||||
| print self.cbpi | |||||
| self.logger.debug(actor_id) | |||||
| self.logger.debug(self.cbpi) | |||||
| class SensorCore(object): | class SensorCore(object): | ||||
| key = "sensor_types" | key = "sensor_types" | ||||
| def __init__(self, cbpi): | def __init__(self, cbpi): | ||||
| self.logger = logging.getLogger(__name__) | |||||
| self.cbpi = cbpi | self.cbpi = cbpi | ||||
| self.cbpi.cache["sensors"] = {} | self.cbpi.cache["sensors"] = {} | ||||
| self.cbpi.cache["sensor_instances"] = {} | self.cbpi.cache["sensor_instances"] = {} | ||||
| @@ -172,7 +177,7 @@ class SensorCore(object): | |||||
| cfg.update(dict(cbpi=self.cbpi, id=id)) | cfg.update(dict(cbpi=self.cbpi, id=id)) | ||||
| self.cbpi.cache["sensors"][id].instance = clazz(**cfg) | self.cbpi.cache["sensors"][id].instance = clazz(**cfg) | ||||
| self.cbpi.cache["sensors"][id].instance.init() | self.cbpi.cache["sensors"][id].instance.init() | ||||
| print self.cbpi.cache["sensors"][id].instance | |||||
| self.logger.debug(self.cbpi.cache["sensors"][id].instance) | |||||
| self.cbpi.emit("INIT_SENSOR", id=id) | self.cbpi.emit("INIT_SENSOR", id=id) | ||||
| def job(obj): | def job(obj): | ||||
| @@ -182,11 +187,10 @@ class SensorCore(object): | |||||
| self.cbpi.emit("INIT_SENSOR", id=id) | self.cbpi.emit("INIT_SENSOR", id=id) | ||||
| except Exception as e: | except Exception as e: | ||||
| print "ERROR" | |||||
| self.cbpi._app.logger.error(e) | |||||
| self.logger.error(e) | |||||
| def stop_one(self, id): | def stop_one(self, id): | ||||
| print "OBJ", self.cbpi.cache["sensors"][id] | |||||
| self.logger.info("OBJ [%s]", self.cbpi.cache["sensors"][id]) | |||||
| self.cbpi.cache["sensors"][id].instance.stop() | self.cbpi.cache["sensors"][id].instance.stop() | ||||
| self.cbpi.emit("STOP_SENSOR", id=id) | self.cbpi.emit("STOP_SENSOR", id=id) | ||||
| @@ -197,8 +201,8 @@ class SensorCore(object): | |||||
| return None | return None | ||||
| def get_state(self, actor_id): | def get_state(self, actor_id): | ||||
| print actor_id | |||||
| print self.cbpi | |||||
| self.logger.info("Get state actor id [%s]", actor_id) | |||||
| self.logger.debug(self.cbpi) | |||||
| def write_log(self, id, value, prefix="sensor"): | def write_log(self, id, value, prefix="sensor"): | ||||
| filename = "./logs/%s_%s.log" % (prefix, str(id)) | filename = "./logs/%s_%s.log" % (prefix, str(id)) | ||||
| @@ -277,8 +281,11 @@ class CraftBeerPI(object): | |||||
| eventbus = {} | eventbus = {} | ||||
| def __init__(self): | def __init__(self): | ||||
| FORMAT = '%(asctime)-15s - %(levelname)s - %(message)s' | |||||
| logging.basicConfig(filename='./logs/app.log', level=logging.INFO, format=FORMAT) | |||||
| #FORMAT = '%(asctime)-15s - %(levelname)s - %(message)s' | |||||
| #logging.basicConfig(filename='./logs/app.log', level=logging.INFO, format=FORMAT) | |||||
| logging.config.dictConfig(yaml.load(open('./config/logger.yaml', 'r'))) | |||||
| self.logger = logging.getLogger(__name__) | |||||
| self.cache["messages"] = [] | self.cache["messages"] = [] | ||||
| self.cache["version"] = "3.1" | self.cache["version"] = "3.1" | ||||
| self.modules = {} | self.modules = {} | ||||
| @@ -324,7 +331,7 @@ class CraftBeerPI(object): | |||||
| self._socketio.emit(key, data, namespace='/brew') | self._socketio.emit(key, data, namespace='/brew') | ||||
| def __init_db(self, ): | def __init_db(self, ): | ||||
| print "INIT DB" | |||||
| self.logger.info("INIT DB") | |||||
| with self._app.app_context(): | with self._app.app_context(): | ||||
| db = self.get_db() | db = self.get_db() | ||||
| try: | try: | ||||
| @@ -332,7 +339,7 @@ class CraftBeerPI(object): | |||||
| db.cursor().executescript(f.read()) | db.cursor().executescript(f.read()) | ||||
| db.commit() | db.commit() | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| pass | pass | ||||
| def nocache(self, view): | def nocache(self, view): | ||||
| @@ -383,13 +390,13 @@ class CraftBeerPI(object): | |||||
| def loadPlugins(self): | def loadPlugins(self): | ||||
| for filename in os.listdir("./modules/plugins"): | for filename in os.listdir("./modules/plugins"): | ||||
| print filename | |||||
| self.logger.info("Loading plugin [%s]", filename) | |||||
| if os.path.isdir("./modules/plugins/" + filename) is False: | if os.path.isdir("./modules/plugins/" + filename) is False: | ||||
| continue | continue | ||||
| try: | try: | ||||
| self.modules[filename] = import_module("modules.plugins.%s" % (filename)) | self.modules[filename] = import_module("modules.plugins.%s" % (filename)) | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| self.notify("Failed to load plugin %s " % filename, str(e), type="danger", timeout=None) | self.notify("Failed to load plugin %s " % filename, str(e), type="danger", timeout=None) | ||||
| @@ -1,3 +1,4 @@ | |||||
| import logging | |||||
| import time | import time | ||||
| from flask import request | from flask import request | ||||
| from flask_classy import route | from flask_classy import route | ||||
| @@ -12,6 +13,8 @@ class FermenterView(BaseView): | |||||
| model = Fermenter | model = Fermenter | ||||
| cache_key = "fermenter" | cache_key = "fermenter" | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| def _post_post_callback(self, m): | def _post_post_callback(self, m): | ||||
| m.state = False | m.state = False | ||||
| @@ -159,7 +162,7 @@ class FermenterView(BaseView): | |||||
| def toggle(self, id): | def toggle(self, id): | ||||
| fermenter = cbpi.cache.get(self.cache_key)[id] | fermenter = cbpi.cache.get(self.cache_key)[id] | ||||
| try: | try: | ||||
| print fermenter.state | |||||
| self.logger.info("Fermenter [%s] is in state [%s]",fermenter.id, fermenter.state) | |||||
| if fermenter.state is False: | if fermenter.state is False: | ||||
| # Start controller | # Start controller | ||||
| if fermenter.logic is not None: | if fermenter.logic is not None: | ||||
| @@ -185,7 +188,7 @@ class FermenterView(BaseView): | |||||
| cbpi.emit("FERMENTER_CONTROLLER_STOPPED", id=id) | cbpi.emit("FERMENTER_CONTROLLER_STOPPED", id=id) | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| cbpi.notify("Toogle Fementer Controller failed", "Pleae check the %s configuration" % fermenter.name, | cbpi.notify("Toogle Fementer Controller failed", "Pleae check the %s configuration" % fermenter.name, | ||||
| type="danger", timeout=None) | type="danger", timeout=None) | ||||
| return ('', 500) | return ('', 500) | ||||
| @@ -1,3 +1,5 @@ | |||||
| import logging | |||||
| from flask import json, request | from flask import json, request | ||||
| from flask_classy import FlaskView, route | from flask_classy import FlaskView, route | ||||
| from git import Repo, Git | from git import Repo, Git | ||||
| @@ -11,6 +13,8 @@ from modules.step import Step, StepView | |||||
| class KBH(FlaskView): | class KBH(FlaskView): | ||||
| def __init__(self): | |||||
| self.logger = logging.getLogger(__name__) | |||||
| @route('/', methods=['GET']) | @route('/', methods=['GET']) | ||||
| def get(self): | def get(self): | ||||
| @@ -39,7 +43,7 @@ class KBH(FlaskView): | |||||
| result.append({"id": row[0], "name": row[1], "brewed": row[2]}) | result.append({"id": row[0], "name": row[1], "brewed": row[2]}) | ||||
| return json.dumps(result) | return json.dumps(result) | ||||
| except Exception as e: | except Exception as e: | ||||
| print e | |||||
| self.logger.error(e) | |||||
| self.api.notify(headline="Failed to load KHB database", message="ERROR", type="danger") | self.api.notify(headline="Failed to load KHB database", message="ERROR", type="danger") | ||||
| return ('', 500) | return ('', 500) | ||||
| finally: | finally: | ||||