Author SHA1 Message Date
manuel83 5e960dce1c cleanup 2019-08-19 23:25:02 +02:00
manuel83 04f67754e5 remove wiringpi 2019-08-19 23:03:48 +02:00
manuel83 bf705e3957 update requirements 2019-08-19 23:03:01 +02:00
manuel83 ecd71e8073 python 3 migration 2019-08-19 22:54:59 +02:00
manuel83 9f2d45d834 python 3 migration 2019-08-19 22:51:47 +02:00
manuel83 996bc54768 python 3 migration 2019-08-19 22:51:08 +02:00
27 changed files with 64 additions and 91 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ craftbeerpi.db
**/node_modules/*
*.pyc
*.templog
venv/
modules/plugins/*
!modules/plugins/__init__.py
*.pyc
-7
View File
@@ -35,13 +35,6 @@ show_menu () {
apt-get -y update; apt-get -y upgrade;
fi
confirmAnswer "Would you like to install wiringPI? This is required to control the GPIO"
if [ $? = 0 ]; then
git clone git://git.drogon.net/wiringPi;
cd wiringPi;
./build; cd ..;
rm -rf wiringPi;
fi
apt-get -y install python-setuptools
easy_install pip
+5 -12
View File
@@ -1,16 +1,9 @@
import json
import pprint
import sys, os
from flask import Flask, render_template, redirect
from flask_socketio import SocketIO, emit
import logging
# Define the WSGI application object
from app_config import *
import pprint
from modules.core.db import get_db
from .app_config import *
@app.route('/')
@@ -30,15 +23,15 @@ import modules.actor
import modules.notification
import modules.fermenter
from modules.addon.endpoints import initPlugins
import modules.ui
import modules.system
import modules.ui.endpoints
import modules.system.endpoints
import modules.buzzer
import modules.stats
import modules.kettle
import modules.recipe_import
import modules.core.db_mirgrate
from app_config import cbpi
from .app_config import cbpi
# Build the database:
# This will create the database file using SQLAlchemy
@@ -47,7 +40,7 @@ pp = pprint.PrettyPrinter(indent=6)
def init_db():
print "INIT DB"
print("INIT DB")
with app.app_context():
db = get_db()
-1
View File
@@ -1 +0,0 @@
import endpoints
+1 -1
View File
@@ -134,7 +134,7 @@ def plugins():
"""
response = requests.get("https://raw.githubusercontent.com/Manuel83/craftbeerpi-plugins/master/plugins.yaml")
cbpi.cache["plugins"] = merge(yaml.load(response.text), cbpi.cache["plugins"])
for key, value in cbpi.cache["plugins"].iteritems():
for key, value in cbpi.cache["plugins"].items():
value["installed"] = os.path.isdir("./modules/plugins/%s/" % (key))
return json.dumps(cbpi.cache["plugins"])
-2
View File
@@ -8,8 +8,6 @@ from flask_socketio import SocketIO, emit
import logging
from modules.core.core import CraftBeerPi, ActorBase, SensorBase
from modules.core.db import DBModel
+1 -1
View File
@@ -15,7 +15,7 @@ class DummyTempSensor(SensorActive):
@cbpi.action("My Custom Action")
def my_action(self):
print "HELLO WORLD"
pass
def get_unit(self):
+6 -6
View File
@@ -10,7 +10,7 @@ try:
GPIO.setmode(GPIO.BCM)
except Exception as e:
print e
print(e)
pass
@@ -25,11 +25,11 @@ class GPIOSimple(ActorBase):
GPIO.output(int(self.gpio), 0)
def on(self, power=0):
print "GPIO ON %s" % str(self.gpio)
print("GPIO ON %s" % str(self.gpio))
GPIO.output(int(self.gpio), 1)
def off(self):
print "GPIO OFF"
print("GPIO OFF")
GPIO.output(int(self.gpio), 0)
@cbpi.actor
@@ -67,7 +67,7 @@ class GPIOPWM(ActorBase):
self.p.ChangeDutyCycle(self.power)
def off(self):
print "GPIO OFF"
print("GPIO OFF")
self.p.stop()
@@ -98,10 +98,10 @@ class Dummy(ActorBase):
:param power: int value between 0 - 100
:return:
'''
print "ON"
print("ON")
def off(self):
print "OFF"
print("OFF")
+3 -3
View File
@@ -1,5 +1,5 @@
import time
from thread import start_new_thread
#from threading import start_new_thread
from modules import cbpi
try:
@@ -44,8 +44,8 @@ class Buzzer(object):
time.sleep(i)
except Exception as e:
pass
start_new_thread(play, (self.sound,))
## TODO
#start_new_thread(play, (self.sound,))
@cbpi.initalizer(order=1)
def init(cbpi):
+1 -1
View File
@@ -46,7 +46,7 @@ class ConfigView(BaseView):
with cls.api.app.app_context():
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][value.name] = value
+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):
+4 -4
View File
@@ -210,7 +210,7 @@ class FermenterView(BaseView):
def toggle(self, id):
fermenter = cbpi.cache.get(self.cache_key)[id]
try:
print fermenter.state
print(fermenter.state)
if fermenter.state is False:
# Start controller
if fermenter.logic is not None:
@@ -236,7 +236,7 @@ class FermenterView(BaseView):
cbpi.emit("UPDATE_FERMENTER", cbpi.cache.get(self.cache_key).get(id))
except Exception as e:
print e
print(e)
cbpi.notify("Toogle Fementer Controller failed", "Pleae check the %s configuration" % fermenter.name,
type="danger", timeout=None)
return ('', 500)
@@ -261,7 +261,7 @@ class FermenterView(BaseView):
cbpi.emit("UPDATE_FERMENTER", cbpi.cache.get(self.cache_key)[id])
def check_step(self):
for key, value in cbpi.cache["fermenter_task"].iteritems():
for key, value in cbpi.cache["fermenter_task"].items():
try:
fermenter = self.get_fermenter(key)
@@ -292,7 +292,7 @@ def read_target_temps(api):
:return: None
"""
result = {}
for key, value in cbpi.cache.get("fermenter").iteritems():
for key, value in cbpi.cache.get("fermenter").items():
cbpi.save_to_file(key, value.target_temp, prefix="fermenter")
+1 -1
View File
@@ -86,7 +86,7 @@ def read_target_temps(api):
:return: None
"""
result = {}
for key, value in cbpi.cache.get("kettle").iteritems():
for key, value in cbpi.cache.get("kettle").items():
cbpi.save_to_file(key, value.target_temp, prefix="kettle")
@cbpi.initalizer()
-1
View File
@@ -1 +0,0 @@
import endpoints
-3
View File
@@ -1,3 +0,0 @@
import beerxml
import kbh
import restapi
+1 -1
View File
@@ -29,7 +29,7 @@ class KBH(FlaskView):
result.append({"id": row[0], "name": row[1], "brewed": row[2]})
return json.dumps(result)
except Exception as e:
print e
print(e)
self.api.notify(headline="Failed to load KHB database", message="ERROR", type="danger")
return ('', 500)
finally:
+1 -1
View File
@@ -43,6 +43,6 @@ def read_passive_sensor(api):
:return: None
"""
for key, value in cbpi.cache.get("sensors").iteritems():
for key, value in cbpi.cache.get("sensors").items():
if value.mode == "P":
value.instance.read()
-1
View File
@@ -1 +0,0 @@
import endpoints
+1 -1
View File
@@ -109,7 +109,7 @@ class SystemView(FlaskView):
vf = self.api.app.view_functions
for f in self.api.app.view_functions:
print f
print(f)
endpoints = {}
re = {
"swagger": "2.0",
-1
View File
@@ -1 +0,0 @@
import endpoints
+14 -14
View File
@@ -1,14 +1,14 @@
Flask==0.12.4
Flask-SocketIO==2.6.2
eventlet==0.19.0
greenlet==0.4.10
python-dateutil==2.5.3
python-engineio==0.9.2
python-mimeparse==1.5.2
python-socketio==1.4.4
PyYAML==4.2b1
requests==2.20.0
Werkzeug==0.11.10
httplib2==0.9.2
flask-classy==0.6.10
GitPython==2.1.3
eventlet==0.25.0
Flask==1.1.1
Flask-Classy==0.6.10
Flask-SocketIO==4.2.1
GitPython==3.0.1
greenlet==0.4.15
httplib2==0.13.1
python-dateutil==2.8.0
python-engineio==3.9.3
python-mimeparse==1.6.0
python-socketio==4.3.1
PyYAML==5.1.2
requests==2.22.0
Werkzeug==0.15.5