Procházet zdrojové kódy

replaced the remaining print statements with calls to logger

pull/147/head
Johannes před 8 roky
rodič
revize
52bb994997
8 změnil soubory, kde provedl 39 přidání a 24 odebrání
  1. +5
    -2
      modules/base_plugins/sensor.py
  2. +1
    -1
      modules/core/baseapi.py
  3. +11
    -10
      modules/core/basetypes.py
  4. +3
    -3
      modules/core/db_migrate.py
  5. +5
    -1
      modules/example_plugins/WebViewJquery/__init__.py
  6. +4
    -1
      modules/example_plugins/WebViewReactJs/__init__.py
  7. +5
    -4
      modules/login/__init__.py
  8. +5
    -2
      modules/ui/__init__.py

+ 5
- 2
modules/base_plugins/sensor.py Zobrazit soubor

@@ -9,7 +9,7 @@ from modules.core.proptypes import Property

import logging

print "INit SENSOR"
@cbpi.addon.sensor.type("Dummy Sensor")
class Dummy(Sensor):

@@ -18,6 +18,7 @@ class Dummy(Sensor):

def __init__(self):
self.logger = logging.getLogger(__name__)
self.logger.info("INIT SENSOR")

def init(self):
if self.api.get_config_parameter("unit","C") == "C":
@@ -40,7 +41,9 @@ class Dummy(Sensor):

@cbpi.addon.core.action(key="clear", label="Clear all Logs")
def woohoo(cbpi):
print "COOL"
logger = logging.getLogger(__name__)
logger.info("COOL")

dir = "./logs"
test = os.listdir(dir)



+ 1
- 1
modules/core/baseapi.py Zobrazit soubor

@@ -224,5 +224,5 @@ class CoreAPI(BaseAPI):
class Buzzer(object):
def beep():
def beep(self):
pass

+ 11
- 10
modules/core/basetypes.py Zobrazit soubor

@@ -14,13 +14,13 @@ class Base(object):
self.value = None
self.__dirty = False
class Actor(Base):
def __init__(self):
self.logger = logging.getLogger(__name__)
__logger = logging.getLogger(__name__)
@classmethod
def init_global(cls):
print "GLOBAL INIT ACTOR"
cls.__logger.info("GLOBAL INIT ACTOR")
pass
def init(self):
@@ -30,15 +30,15 @@ class Actor(Base):
pass
def on(self, power=100):
self.logger.info("SWITCH ON")
self._logger.info("SWITCH ON")
pass
def off(self):
self.logger.info("SWITCH OFF")
self._logger.info("SWITCH OFF")
pass
def power(self, power):
self.logger.info("SET POWER TO [%s]", power)
self._logger.info("SET POWER TO [%s]", power)
pass
def state(self):
@@ -46,8 +46,7 @@ class Actor(Base):
class Sensor(Base):
def __init__(self):
self.logger = logging.getLogger(__name__)
__logger = logging.getLogger(__name__)
unit = ""
@@ -71,7 +70,7 @@ class Sensor(Base):
self.cbpi.ws_emit("SENSOR_UPDATE", self.cbpi.cache["sensors"][self.id])
def execute(self):
self.logger.info("EXECUTE")
self.__logger.info("EXECUTE")
pass
@@ -81,9 +80,11 @@ class ControllerBase(object):
__dirty = False
__running = False
__logger = logging.getLogger(__name__)
@staticmethod
def init_global():
print "GLOBAL CONTROLLER INIT"
ControllerBase.__logger.info("GLOBAL CONTROLLER INIT")
def notify(self, headline, message, type="success", timeout=5000):
self.api.notify(headline, message, type, timeout)


+ 3
- 3
modules/core/db_migrate.py Zobrazit soubor

@@ -19,8 +19,8 @@ def execute_file(curernt_version, data):
conn.commit()

except sqlite3.OperationalError as err:
print "EXCEPT"
print err
cbpi._app.logger.info("EXCEPT")
cbpi._app.logger.error(err)

@cbpi.addon.core.initializer(order=-9999)
def init(cbpi):
@@ -37,7 +37,7 @@ def init(cbpi):
pass
result = []
for filename in os.listdir("./update"):
print filename
cbpi._app.logger.info(filename)
if filename.endswith(".sql"):
d = {"version": int(filename[:filename.index('_')]), "file": filename}
result.append(d)

+ 5
- 1
modules/example_plugins/WebViewJquery/__init__.py Zobrazit soubor

@@ -5,15 +5,19 @@ from flask_swagger import swagger
from flask import json
from flask import Blueprint

import logging

@addon.core.initializer(order=22)
def web(cbpi):

logger = logging.getLogger(__name__)

s = Blueprint('web_view', __name__, template_folder='templates', static_folder='static')

@s.route('/', methods=["GET"])
def index():
return s.send_static_file("index.html")

print "REGISTER"
logger.info("REGISTER")
cbpi.addon.core.add_menu_link("JQuery View", "/web_view")
cbpi._app.register_blueprint(s, url_prefix='/web_view')

+ 4
- 1
modules/example_plugins/WebViewReactJs/__init__.py Zobrazit soubor

@@ -5,8 +5,11 @@ from flask_swagger import swagger
from flask import json
from flask import Blueprint

import logging

@addon.core.initializer(order=22)
def web(cbpi):
logger = logging.getLogger(__name__)

s = Blueprint('webviewreact', __name__, template_folder='templates', static_folder='static')

@@ -14,6 +17,6 @@ def web(cbpi):
def index():
return s.send_static_file("index.html")

print "REGISTER"
logger.info("REGISTER")
cbpi.addon.core.add_menu_link("ReactJS View", "/webviewreact")
cbpi._app.register_blueprint(s, url_prefix='/webviewreact')

+ 5
- 4
modules/login/__init__.py Zobrazit soubor

@@ -3,12 +3,14 @@ from flask import request

from modules.core.core import cbpi, addon

import logging

class User(flask_login.UserMixin):
pass

@addon.core.initializer(order=0)
def log(cbpi):
logger = logging.getLogger(__name__)

cbpi._login_manager = flask_login.LoginManager()
cbpi._login_manager.init_app(cbpi._app)
@@ -37,9 +39,8 @@ def log(cbpi):

@cbpi._login_manager.user_loader
def user_loader(user):

print cbpi.get_config_parameter("password_security", "NO")
print user
logger.debug(cbpi.get_config_parameter("password_security", "NO"))
logger.debug(user)

if cbpi.get_config_parameter("password_security", "NO") == "YES":
if user != "craftbeerpi":


+ 5
- 2
modules/ui/__init__.py Zobrazit soubor

@@ -2,7 +2,10 @@ from flask import Blueprint,render_template

from modules.core.core import cbpi

import logging

react = Blueprint('ui', __name__, template_folder='templates', static_folder='static')
__logger = logging.getLogger(__name__)

@cbpi.addon.core.initializer(order=10)
def init(cbpi):
@@ -11,13 +14,13 @@ def init(cbpi):

@react.route('/', methods=["GET"])
def index():
#return react.send_static_file("index.html")
# return react.send_static_file("index.html")

js_files = []
for key, value in cbpi.cache["js"].iteritems():
js_files.append(value)

print js_files
__logger.info(js_files)
return render_template('index.html', js_files=js_files)




Načítá se…
Zrušit
Uložit