| @@ -0,0 +1,7 @@ | |||||
| from git import Repo, Git | |||||
| repo = Repo('./') | |||||
| print repo | |||||
| for remote in repo.remotes: | |||||
| print remote | |||||
| remote.fetch()ls | |||||
| @@ -15,7 +15,7 @@ class ActionView(FlaskView): | |||||
| 200: | 200: | ||||
| description: action invoked | description: action invoked | ||||
| """ | """ | ||||
| print self.cbpi.cache["actions"] | |||||
| self.cbpi.cache["actions"][action]["function"](self.cbpi) | self.cbpi.cache["actions"][action]["function"](self.cbpi) | ||||
| return ('',204) | return ('',204) | ||||
| @@ -8,7 +8,7 @@ class Dummy(Actor): | |||||
| @cbpi.addon.actor.action("WOHOO") | @cbpi.addon.actor.action("WOHOO") | ||||
| def myaction(self): | def myaction(self): | ||||
| print "HALLO!!!" | |||||
| pass | |||||
| def on(self, power=100): | def on(self, power=100): | ||||
| ''' | ''' | ||||
| @@ -28,7 +28,7 @@ class MyController(KettleController): | |||||
| def run(self): | def run(self): | ||||
| while self.is_running(): | while self.is_running(): | ||||
| print "HALLO" | |||||
| self.sleep(1) | self.sleep(1) | ||||
| @cbpi.addon.fermenter.controller() | @cbpi.addon.fermenter.controller() | ||||
| @@ -45,6 +45,6 @@ def init(cbpi): | |||||
| class MyBuzzer(Buzzer): | class MyBuzzer(Buzzer): | ||||
| def beep(self): | def beep(self): | ||||
| print "BEEEEEEP" | |||||
| pass | |||||
| cbpi.buzzer = MyBuzzer() | cbpi.buzzer = MyBuzzer() | ||||
| @@ -7,7 +7,7 @@ from modules.core.basetypes import Actor, 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 random | ||||
| print "INit SENSOR" | |||||
| @cbpi.addon.sensor.type("Dummy Sensor") | @cbpi.addon.sensor.type("Dummy Sensor") | ||||
| class Dummy(Sensor): | class Dummy(Sensor): | ||||
| @@ -23,7 +23,7 @@ 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!!!" | print "SENSOR ACTION HALLO!!!" | ||||
| def execute(self): | def execute(self): | ||||
| @@ -36,7 +36,7 @@ class Dummy(Sensor): | |||||
| @cbpi.addon.core.action(key="clear", label="Clear all Logs") | @cbpi.addon.core.action(key="clear", label="Clear all Logs") | ||||
| def woohoo(cbpi): | def woohoo(cbpi): | ||||
| print "COOL" | |||||
| dir = "./logs" | dir = "./logs" | ||||
| test = os.listdir(dir) | test = os.listdir(dir) | ||||
| @@ -11,7 +11,7 @@ class Dummy(Step): | |||||
| def myaction(self): | def myaction(self): | ||||
| self.stop_timer() | self.stop_timer() | ||||
| self.start_timer(10) | self.start_timer(10) | ||||
| print "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") | ||||
| @@ -21,5 +21,5 @@ class Dummy(Step): | |||||
| pass | pass | ||||
| def reset(self): | def reset(self): | ||||
| print "RESET STEP!!!" | |||||
| self.stop_timer() | self.stop_timer() | ||||
| @@ -160,7 +160,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 | |||||
| value["function"](self.cbpi) | value["function"](self.cbpi) | ||||
| def job(interval, method): | def job(interval, method): | ||||
| @@ -16,7 +16,7 @@ class Actor(Base): | |||||
| @classmethod | @classmethod | ||||
| def init_global(cls): | def init_global(cls): | ||||
| print "GLOBAL INIT ACTOR" | |||||
| pass | pass | ||||
| def init(self): | def init(self): | ||||
| @@ -251,7 +251,7 @@ class Step(Base, Timer): | |||||
| pass | pass | ||||
| def execute(self): | def execute(self): | ||||
| print "-------------" | |||||
| print "Step Info" | print "Step Info" | ||||
| print "Kettle ID: %s" % self.kettle_id | print "Kettle ID: %s" % self.kettle_id | ||||
| print "ID: %s" % self.id | print "ID: %s" % self.id | ||||
| @@ -72,7 +72,7 @@ class ActorCore(object): | |||||
| def init_one(self, id): | def init_one(self, id): | ||||
| try: | try: | ||||
| print "INIT ONE ACTOR", 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() | ||||
| @@ -147,8 +147,7 @@ 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 | |||||
| pass | |||||
| class SensorCore(object): | class SensorCore(object): | ||||
| @@ -172,7 +171,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.cbpi.emit("INIT_SENSOR", id=id) | self.cbpi.emit("INIT_SENSOR", id=id) | ||||
| def job(obj): | def job(obj): | ||||
| @@ -186,7 +185,7 @@ class SensorCore(object): | |||||
| self.cbpi._app.logger.error(e) | self.cbpi._app.logger.error(e) | ||||
| def stop_one(self, id): | def stop_one(self, id): | ||||
| print "OBJ", 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 +196,7 @@ 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 | |||||
| pass | |||||
| 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)) | ||||
| @@ -308,6 +306,7 @@ class CraftBeerPI(object): | |||||
| port = int(cbpi.get_config_parameter('port', '5000')) | port = int(cbpi.get_config_parameter('port', '5000')) | ||||
| except ValueError: | except ValueError: | ||||
| port = 5000 | port = 5000 | ||||
| print port | |||||
| self._socketio.run(self._app, host='0.0.0.0', port=port) | self._socketio.run(self._app, host='0.0.0.0', port=port) | ||||
| def beep(self): | def beep(self): | ||||
| @@ -324,7 +323,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" | |||||
| with self._app.app_context(): | with self._app.app_context(): | ||||
| db = self.get_db() | db = self.get_db() | ||||
| try: | try: | ||||
| @@ -332,7 +331,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 | |||||
| pass | pass | ||||
| def nocache(self, view): | def nocache(self, view): | ||||
| @@ -383,13 +382,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 | |||||
| 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.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) | ||||
| @@ -19,7 +19,7 @@ def execute_file(curernt_version, data): | |||||
| conn.commit() | conn.commit() | ||||
| except sqlite3.OperationalError as err: | except sqlite3.OperationalError as err: | ||||
| print "EXCEPT" | |||||
| print err | print err | ||||
| @cbpi.addon.core.initializer(order=-9999) | @cbpi.addon.core.initializer(order=-9999) | ||||
| @@ -37,7 +37,7 @@ def init(cbpi): | |||||
| pass | pass | ||||
| result = [] | result = [] | ||||
| for filename in os.listdir("./update"): | for filename in os.listdir("./update"): | ||||
| print filename | |||||
| if filename.endswith(".sql"): | if filename.endswith(".sql"): | ||||
| d = {"version": int(filename[:filename.index('_')]), "file": filename} | d = {"version": int(filename[:filename.index('_')]), "file": filename} | ||||
| result.append(d) | result.append(d) | ||||
| @@ -14,6 +14,6 @@ def web(cbpi): | |||||
| def index(): | def index(): | ||||
| return s.send_static_file("index.html") | return s.send_static_file("index.html") | ||||
| print "REGISTER" | |||||
| cbpi.addon.core.add_menu_link("JQuery View", "/web_view") | cbpi.addon.core.add_menu_link("JQuery View", "/web_view") | ||||
| cbpi._app.register_blueprint(s, url_prefix='/web_view') | cbpi._app.register_blueprint(s, url_prefix='/web_view') | ||||
| @@ -14,6 +14,6 @@ def web(cbpi): | |||||
| def index(): | def index(): | ||||
| return s.send_static_file("index.html") | return s.send_static_file("index.html") | ||||
| print "REGISTER" | |||||
| cbpi.addon.core.add_menu_link("ReactJS View", "/webviewreact") | cbpi.addon.core.add_menu_link("ReactJS View", "/webviewreact") | ||||
| cbpi._app.register_blueprint(s, url_prefix='/webviewreact') | cbpi._app.register_blueprint(s, url_prefix='/webviewreact') | ||||
| @@ -159,7 +159,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 | |||||
| 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 +185,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 | |||||
| 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) | ||||
| @@ -38,8 +38,7 @@ def log(cbpi): | |||||
| @cbpi._login_manager.user_loader | @cbpi._login_manager.user_loader | ||||
| def user_loader(user): | def user_loader(user): | ||||
| print cbpi.get_config_parameter("password_security", "NO") | |||||
| print user | |||||
| if cbpi.get_config_parameter("password_security", "NO") == "YES": | if cbpi.get_config_parameter("password_security", "NO") == "YES": | ||||
| if user != "craftbeerpi": | if user != "craftbeerpi": | ||||
| @@ -1,4 +1,5 @@ | |||||
| import flask_login | import flask_login | ||||
| import requests | |||||
| import yaml | import yaml | ||||
| from flask import json, url_for, Response | from flask import json, url_for, Response | ||||
| from flask_classy import FlaskView, route | from flask_classy import FlaskView, route | ||||
| @@ -68,6 +69,25 @@ class SystemView(FlaskView): | |||||
| @login_required | @login_required | ||||
| @route('/git/status', methods=['GET']) | @route('/git/status', methods=['GET']) | ||||
| def git_status(self): | def git_status(self): | ||||
| repo = Repo('./') | |||||
| for remote in repo.remotes: | |||||
| print remote | |||||
| #o = repo.remotes.origin | |||||
| #o.fetch() | |||||
| print next((tag for tag in repo.tags if tag.commit == repo.head.commit), None) | |||||
| url = 'https://api.github.com/repos/manuel83/craftbeerpi3/releases' | |||||
| response = requests.get(url) | |||||
| data = response.json() | |||||
| result = [] | |||||
| for r in data: | |||||
| result.append({"tag_name": r.get("tag_name"), "timestamp": r.get("created_at")}) | |||||
| """ | """ | ||||
| Check for GIT status | Check for GIT status | ||||
| --- | --- | ||||
| @@ -77,28 +97,7 @@ class SystemView(FlaskView): | |||||
| 200: | 200: | ||||
| description: Git Status | description: Git Status | ||||
| """ | """ | ||||
| repo = Repo('./') | |||||
| o = repo.remotes.origin | |||||
| o.fetch() | |||||
| # Tags | |||||
| tags = [] | |||||
| for t in repo.tags: | |||||
| tags.append({"name": t.name, "commit": str(t.commit), "date": t.commit.committed_date, | |||||
| "committer": t.commit.committer.name, "message": t.commit.message}) | |||||
| try: | |||||
| branch_name = repo.active_branch.name | |||||
| # test1 | |||||
| except: | |||||
| branch_name = None | |||||
| changes = [] | |||||
| commits_behind = repo.iter_commits('master..origin/master') | |||||
| for c in list(commits_behind): | |||||
| changes.append({"committer": c.committer.name, "message": c.message}) | |||||
| return json.dumps({"tags": tags, "headcommit": str(repo.head.commit), "branchname": branch_name, | |||||
| "master": {"changes": changes}}) | |||||
| return json.dumps(result) | |||||
| @login_required | @login_required | ||||
| @route('/check_update', methods=['GET']) | @route('/check_update', methods=['GET']) | ||||
| @@ -17,7 +17,7 @@ def index(): | |||||
| for key, value in cbpi.cache["js"].iteritems(): | for key, value in cbpi.cache["js"].iteritems(): | ||||
| js_files.append(value) | js_files.append(value) | ||||
| print js_files | |||||
| return render_template('index.html', js_files=js_files) | return render_template('index.html', js_files=js_files) | ||||