python 3 migration

This commit is contained in:
manuel83
2019-08-19 22:51:08 +02:00
parent 63f9f5468b
commit 996bc54768
1363 changed files with 351010 additions and 62 deletions
+1 -1
View File
@@ -104,6 +104,6 @@ class BaseView(FlaskView):
cls.api.cache[cls.cache_key].append(value)
else:
cls.api.cache[cls.cache_key] = {}
for key, value in cls.model.get_all().iteritems():
for key, value in cls.model.get_all().items():
cls.post_init_callback(value)
cls.api.cache[cls.cache_key][key] = value
+1 -1
View File
@@ -42,7 +42,7 @@ class ControllerBase(object):
@staticmethod
def init_global():
print "GLOBAL CONTROLLER INIT"
print("GLOBAL CONTROLLER INIT")
def notify(self, headline, message, type="success", timeout=5000):
self.api.notify(headline, message, type, timeout)
+7 -10
View File
@@ -12,9 +12,9 @@ from time import localtime, strftime
from functools import wraps, update_wrapper
from props import *
from .props import *
from hardware import *
from .hardware import *
import time
import uuid
@@ -28,7 +28,7 @@ class ActorAPI(object):
def init_actors(self):
self.app.logger.info("Init Actors")
t = self.cache.get("actor_types")
for key, value in t.iteritems():
for key, value in t.items():
value.get("class").api = self
value.get("class").init_global()
@@ -89,7 +89,7 @@ class SensorAPI(object):
self.app.logger.info("Init Sensors")
t = self.cache.get("sensor_types")
for key, value in t.iteritems():
for key, value in t.items():
value.get("class").init_global()
for key in self.cache.get("sensors"):
@@ -292,7 +292,7 @@ class CraftBeerPi(ActorAPI, SensorAPI):
t = tmpObj.__getattribute__(m)
self.cache[key][name]["properties"].append({"name": m, "label": t.label, "type": "kettle", "configurable": t.configurable, "description": t.description})
for name, method in cls.__dict__.iteritems():
for name, method in cls.__dict__.items():
if hasattr(method, "action"):
label = method.__getattribute__("label")
self.cache[key][cls.__name__]["actions"].append({"method": name, "label": label})
@@ -309,10 +309,7 @@ class CraftBeerPi(ActorAPI, SensorAPI):
def actor2(self, description="", power=True, **options):
def decorator(f):
print f()
print f
print options
print description
return f
return decorator
@@ -369,7 +366,7 @@ class CraftBeerPi(ActorAPI, SensorAPI):
t = tmpObj.__getattribute__(m)
self.cache[key][name]["properties"].append({"name": m, "label": t.label, "type": "kettle", "configurable": t.configurable, "description": t.description})
for name, method in cls.__dict__.iteritems():
for name, method in cls.__dict__.items():
if hasattr(method, "action"):
label = method.__getattribute__("label")
self.cache[key][cls.__name__]["actions"].append({"method": name, "label": label})
+1 -1
View File
@@ -79,7 +79,7 @@ class DBModel(object):
cur = get_db().cursor()
if cls.__priamry_key__ is not None and kwargs.has_key(cls.__priamry_key__):
if cls.__priamry_key__ is not None and cls.__priamry_key__ in kwargs:
query = "INSERT INTO %s (%s, %s) VALUES (?, %s)" % (
cls.__table_name__,
cls.__priamry_key__,
+6 -3
View File
@@ -1,12 +1,15 @@
import sqlite3
import os
from modules import cbpi
from db import get_db
from .db import get_db
def execute_file(curernt_version, data):
# TODO add if block
'''
if curernt_version >= data["version"]:
cbpi.app.logger.info("SKIP DB FILE: %s" % data["file"])
return
'''
try:
with sqlite3.connect("craftbeerpi.db") as conn:
with open('./update/%s' % data["file"], 'r') as f:
@@ -19,8 +22,8 @@ def execute_file(curernt_version, data):
conn.commit()
except sqlite3.OperationalError as err:
print "EXCEPT"
print err
print("EXCEPT")
print(err)
@cbpi.initalizer(order=-9999)
def init(app=None):
+4 -8
View File
@@ -40,18 +40,16 @@ class Base(object):
class SensorBase(Base):
last_value = 0
def init(self):
print "INIT Base SENSOR"
print("INIT Base SENSOR")
def stop(self):
print "STOP SENSOR"
print("STOP SENSOR")
def data_received(self, data):
self.last_value = data
self.api.receive_sensor_value(self.id, data)
@@ -65,12 +63,11 @@ class SensorBase(Base):
return {"value": self.last_value, "unit": self.get_unit()}
class SensorActive(SensorBase):
class SensorActive(SensorBase):
__running = False
def is_running(self):
return self.__running
def init(self):
@@ -79,14 +76,13 @@ class SensorActive(SensorBase):
def stop(self):
self.__running = False
def execute(self):
pass
class SensorPassive(SensorBase):
def init(self):
print "INIT PASSIV SENSOR"
print("INIT PASSIV SENSOR")
pass
def read(self):
+4 -4
View File
@@ -109,10 +109,10 @@ class StepBase(Timer, ActorAPI, SensorAPI, KettleAPI):
pass
def execute(self):
print "-------------"
print "Step Info"
print "Kettle ID: %s" % self.kettle_id
print "ID: %s" % self.id
print("-------------")
print("Step Info")
print("Kettle ID: %s" % self.kettle_id)
print("ID: %s" % self.id)
def __init__(self, *args, **kwds):