-Ui Changes

-Brew Steps added
-Clean AddOn Dialog
This commit is contained in:
Manuel83
2017-06-25 21:29:45 +02:00
parent f0b7c6e640
commit 00739ea38f
21 changed files with 297 additions and 75 deletions
+17 -7
View File
@@ -1,3 +1,4 @@
import inspect
import pprint
import sqlite3
@@ -28,6 +29,7 @@ class ActorAPI(object):
self.app.logger.info("Init Actors")
t = self.cache.get("actor_types")
for key, value in t.iteritems():
value.get("class").api = self
value.get("class").init_global()
for key in self.cache.get("actors"):
@@ -73,12 +75,8 @@ class ActorAPI(object):
if actor.state == 0:
return
actor.instance.off()
actor.state = 0
self.emit("SWITCH_ACTOR", actor)
class SensorAPI(object):
@@ -231,7 +229,6 @@ class CraftBeerPi(ActorAPI, SensorAPI):
self.emit("NOTIFY", msg)
def beep(self):
if self.buzzer is not None:
self.buzzer.beep()
@@ -286,6 +283,15 @@ class CraftBeerPi(ActorAPI, SensorAPI):
def actor(self, cls):
return self.__parseProps("actor_types", cls)
def actor2(self, description="", power=True, **options):
def decorator(f):
print f()
print options
print description
return f
return decorator
def sensor(self, cls):
return self.__parseProps("sensor_types", cls)
@@ -320,9 +326,13 @@ class CraftBeerPi(ActorAPI, SensorAPI):
for m in members:
if isinstance(tmpObj.__getattribute__(m), StepProperty.Number):
t = tmpObj.__getattribute__(m)
self.cache[key][name]["properties"].append({"name": m, "label": t.label, "type": "number", "configurable": t.configurable})
print t.__dict__
#self.cache[key][name]["properties"].append(t.__dict__)
self.cache[key][name]["properties"].append({"name": m, "label": t.label, "type": "number", "configurable": t.configurable, "default_value": t.default_value})
elif isinstance(tmpObj.__getattribute__(m), StepProperty.Text):
t = tmpObj.__getattribute__(m)
print t.__dict__
#self.cache[key][name]["properties"].append(t.__dict__)
self.cache[key][name]["properties"].append({"name": m, "label": t.label, "type": "text", "configurable": t.configurable})
elif isinstance(tmpObj.__getattribute__(m), StepProperty.Select):
t = tmpObj.__getattribute__(m)
@@ -420,7 +430,7 @@ class CraftBeerPi(ActorAPI, SensorAPI):
self.app.logger.info("Invoke Init")
self.cache["init"] = sorted(self.cache["init"], key=lambda k: k['order'])
for i in self.cache.get("init"):
self.app.logger.info("-> %s " % i.get("function").__name__)
self.app.logger.info("INITIALIZER - METHOD %s PAHT %s: " % (i.get("function").__name__, str(inspect.getmodule(i.get("function")).__file__) ))
i.get("function")(self)
+4 -2
View File
@@ -42,13 +42,15 @@ class DBModel(object):
def get_all(cls):
cur = get_db().cursor()
if cls.__order_by__ is not None:
cur.execute("SELECT * FROM %s ORDER BY '%s'" % (cls.__table_name__,cls.__order_by__))
cur.execute("SELECT * FROM %s ORDER BY %s.'%s'" % (cls.__table_name__,cls.__table_name__,cls.__order_by__))
else:
cur.execute("SELECT * FROM %s" % cls.__table_name__)
if cls.__as_array__ is True:
result = []
for r in cur.fetchall():
result.append( cls(r))
else:
result = {}
@@ -104,7 +106,7 @@ class DBModel(object):
else:
data = data + (kwargs.get(f),)
print query, data
cur.execute(query, data)
get_db().commit()
i = cur.lastrowid
+3
View File
@@ -10,6 +10,9 @@ class Base(object):
def get_config_parameter(self, key, default_value):
return self.api.get_config_parameter(key, default_value)
def sleep(self, seconds):
self.api.socketio.sleep(seconds)
def init(self):
print "INIT BASE"
+2 -1
View File
@@ -9,10 +9,11 @@ class Property(object):
self.options = options
class Number(PropertyType):
def __init__(self, label, configurable=False, default_value=0, unit=""):
def __init__(self, label, configurable=False, default_value=None, unit=""):
PropertyType.__init__(self)
self.label = label
self.configurable = configurable
self.default_value = default_value
class Text(PropertyType):
def __init__(self, label, configurable=False, default_value=""):