Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contributing back jpgimenez changes to cbpi3 #258

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
79ff35f
check_hop_timer skip empty values
Nov 14, 2019
ed441f3
- GPIOPWM only set power if the actor is on
Nov 14, 2019
1397284
add space to propper logging the failing method name
Nov 14, 2019
511c119
migrate to py3.5
Juan-gimenez-globant Jul 31, 2020
16cd2e1
update ignores
Juan-gimenez-globant Aug 1, 2020
467b3fe
Merge branch 'python3-support'
Juan-gimenez-globant Aug 1, 2020
f9a92fb
Bump python-engineio from 0.9.2 to 3.8.2.post1
dependabot[bot] Aug 1, 2020
d1ff30d
Bump httplib2 from 0.9.2 to 0.18.0
dependabot[bot] Aug 1, 2020
cef9dbf
Merge pull request #4 from jpgimenez/dependabot/pip/httplib2-0.18.0
jpgimenez Aug 1, 2020
9d33987
Bump flask from 0.12.4 to 1.0
dependabot[bot] Aug 1, 2020
b5626d5
Bump werkzeug from 0.11.10 to 0.15.3
dependabot[bot] Aug 1, 2020
b46c50c
Merge pull request #3 from jpgimenez/dependabot/pip/flask-1.0
jpgimenez Aug 2, 2020
874ce37
Merge pull request #2 from jpgimenez/dependabot/pip/werkzeug-0.15.3
jpgimenez Aug 2, 2020
a5d85d5
Merge pull request #1 from jpgimenez/dependabot/pip/python-engineio-3…
jpgimenez Aug 2, 2020
4093b6c
Add support for SSL.
mstrinzha Apr 8, 2020
5d887d8
updated plugins list
jpgimenez Aug 2, 2020
3330583
migrate to Flask 1.1 and Python 3.8
Juan-gimenez-globant Aug 3, 2020
b5eb699
lint
Juan-gimenez-globant Aug 4, 2020
e03ab9c
ignore .vscode
Juan-gimenez-globant Aug 4, 2020
f14b3c9
add eventlet dep...
jpgimenez Aug 4, 2020
33626e2
python3 support
jpgimenez Aug 4, 2020
8ded4a1
update python-engineio
jpgimenez Aug 4, 2020
184a939
Merge branch 'master' of github.com:jpgimenez/craftbeerpi3
jpgimenez Aug 4, 2020
a05c6e6
use ImportError that is compatible with python 3.5
jpgimenez Aug 5, 2020
0a1b824
change update_addon to delete/download if the repo_url was changed
jpgimenez Aug 6, 2020
4d0807d
fix csv reading
jpgimenez Aug 8, 2020
93aaa66
lint endpoints
jpgimenez Aug 8, 2020
a6ed3f7
add settings to simulate a real sensor...
jpgimenez Aug 8, 2020
eb1c5af
lint
jpgimenez Aug 8, 2020
387e508
add dev deps
jpgimenez Aug 8, 2020
b63d83c
Merge branch 'dummy-sensor-improvements'
jpgimenez Aug 8, 2020
df8c6a7
fix charts
jpgimenez Aug 8, 2020
a497c01
fix up/down toogle
jpgimenez Aug 9, 2020
d482337
* migrate install to python3
jpgimenez Aug 9, 2020
79520bd
typo
jpgimenez Aug 9, 2020
f8ebf83
add dep
jpgimenez Aug 10, 2020
aae37b8
add pdbpp to dev req...
jpgimenez Aug 10, 2020
86e2fca
force temp to float
jpgimenez Aug 10, 2020
ae64ba1
include PWM fix from https://github.com/PaulKGrimes/craftbeerpi3/tree…
jpgimenez Aug 10, 2020
2fc012a
fix for fermenter view
jpgimenez Aug 11, 2020
6a72d86
Update __init__.py
lalo-uy Aug 14, 2020
13951fc
Merge pull request #8 from lalo-uy/patch-3
jpgimenez Aug 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ yarn.lock


modules/ui/package-lock.json

.python-version
upload/*
*.bak
.vscode
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

# - repo: https://github.com/pycqa/pylint
# rev: pylint-2.5.3
# hooks:
# - id: pylint
# stages: [commit]
# additional_dependencies: [pylint-flask]

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Dockerfile for development on a pc/mac
FROM python:2
FROM python:3.8

EXPOSE 5000

Expand All @@ -11,4 +11,4 @@ RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD ["python", "run.py"]
CMD ["python", "run.py"]
69 changes: 69 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "debian/buster64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
config.vm.network "forwarded_port", guest: 5000, host: 5000, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
# end
#
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
sudo /vagrant/install.sh
SHELL
end
10 changes: 5 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ show_menu () {
apt-get -y update; apt-get -y upgrade;
fi

apt-get -y install python-setuptools
easy_install pip
apt-get -y install python-dev
apt-get -y install libpcre3-dev
pip install -r requirements.txt
# apt-get -y install python-setuptools
# easy_install pip
apt-get -y install python3-pip python3-dev python3-rpi.gpio
apt-get -y install libpcre3-dev git
pip3 install -r requirements.txt

confirmAnswer "Would you like to add active 1-wire support at your Raspberry PI now? IMPORTANT: The 1-wire thermometer must be conneted to GPIO 4!"
if [ $? = 0 ]; then
Expand Down
142 changes: 71 additions & 71 deletions modules/__init__.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
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
@app.route('/')
def index():
return redirect('ui')
# Define the database object which is imported
# by modules and controllers
import modules.steps
import modules.config
import modules.logs
import modules.sensors
import modules.actor
import modules.notification
import modules.fermenter
from modules.addon.endpoints import initPlugins
import modules.ui
import modules.system
import modules.buzzer
import modules.stats
import modules.kettle
import modules.recipe_import
import modules.core.db_mirgrate
from app_config import cbpi
# Build the database:
# This will create the database file using SQLAlchemy
pp = pprint.PrettyPrinter(indent=6)
def init_db():
print "INIT DB"
with app.app_context():
db = get_db()
try:
with app.open_resource('../config/schema.sql', mode='r') as f:
db.cursor().executescript(f.read())
db.commit()
except Exception as e:
pass
init_db()
initPlugins()
cbpi.run_init()
cbpi.run_background_processes()
app.logger.info("##########################################")
app.logger.info("### STARTUP COMPLETE")
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 modules.app_config import *
import pprint

from modules.core.db import get_db


@app.route('/')
def index():
return redirect('ui')


# Define the database object which is imported
# by modules and controllers


import modules.steps
import modules.config
import modules.logs
import modules.sensors
import modules.actor
import modules.notification
import modules.fermenter
from modules.addon.endpoints import initPlugins
import modules.ui
import modules.system
import modules.buzzer
import modules.stats
import modules.kettle
import modules.recipe_import
import modules.core.db_mirgrate

from .app_config import cbpi
# Build the database:
# This will create the database file using SQLAlchemy


pp = pprint.PrettyPrinter(indent=6)


def init_db():
print("INIT DB")
with app.app_context():
db = get_db()

try:
with app.open_resource('../config/schema.sql', mode='r') as f:
db.cursor().executescript(f.read())

db.commit()
except Exception as e:
pass

init_db()
initPlugins()
cbpi.run_init()

cbpi.run_background_processes()



app.logger.info("##########################################")
app.logger.info("### STARTUP COMPLETE")
app.logger.info("##########################################")
2 changes: 1 addition & 1 deletion modules/addon/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import endpoints
import modules.addon.endpoints
36 changes: 28 additions & 8 deletions modules/addon/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import requests
import yaml
import shutil
import imp

blueprint = Blueprint('addon', __name__)

Expand All @@ -24,7 +25,7 @@ def merge(source, destination):
:param destination:
:return:
"""
for key, value in source.items():
for key, value in list(source.items()):
if isinstance(value, dict):
# get node or create one
node = destination.setdefault(key, {})
Expand Down Expand Up @@ -115,7 +116,7 @@ def reload(name):
"""
try:
if name in cache["modules"]:
reload(cache["modules"][name])
imp.reload(cache["modules"][name])
cbpi.emit_message("REALOD OF PLUGIN %s SUCCESSFUL" % (name))
return ('', 204)
else:
Expand All @@ -132,9 +133,9 @@ def plugins():
Read the central plugin yaml to get a list of all official plugins
:return:
"""
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():
response = requests.get("https://raw.githubusercontent.com/jpgimenez/craftbeerpi-plugins/master/plugins.yaml")
cbpi.cache["plugins"] = merge(yaml.safe_load(response.text), cbpi.cache["plugins"])
for key, value in cbpi.cache["plugins"].items():
value["installed"] = os.path.isdir("./modules/plugins/%s/" % (key))

return json.dumps(cbpi.cache["plugins"])
Expand All @@ -144,9 +145,9 @@ def plugins():
def download_addon(name):

plugin = cbpi.cache["plugins"].get(name)
plugin["loading"] = True
if plugin is None:
return ('', 404)
plugin["loading"] = True
try:
Repo.clone_from(plugin.get("repo_url"), "./modules/plugins/%s/" % (name))
cbpi.notify("Download successful", "Plugin %s downloaded successfully" % name)
Expand All @@ -157,9 +158,28 @@ def download_addon(name):

@blueprint.route('/<name>/update', methods=['POST'])
def update_addon(name):
"""
Updates a addon

:param name: plugin name
:return: HTTP 204 if ok - HTTP 500 if plugin not exists
"""
plugin = cbpi.cache["plugins"].get(name)
if plugin is None:
return ('', 404)
plugin["loading"] = True

repo = Repo("./modules/plugins/%s/" % (name))
o = repo.remotes.origin
info = o.pull()
if repo.remotes.origin.url == plugin.get('repo_url'):
o = repo.remotes.origin
_info = o.pull()
else:
# url has changed the plugin needs to be re-downloaded
deletePlugin(name)
return download_addon(name)

reload(name)
plugin["loading"] = False
cbpi.notify("Plugin Updated", "Plugin %s updated successfully. Please restart the system" % name)
return ('', 204)

Expand Down
Loading