Skip to content

Commit 73b5dbe

Browse files
committed
v8.15.11 bugfix release
1 parent a49f77c commit 73b5dbe

File tree

7 files changed

+75
-16
lines changed

7 files changed

+75
-16
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 8.15.11 (2023.10.18)
2+
3+
This release fixes a bug that prevents installing some dependencies.
4+
5+
### Bugfixes
6+
7+
- Fix issue installing some dependencies
8+
- Fix automatically reloading the frontend when adding certain Widgets
9+
10+
111
## 8.15.10 (2023.10.15)
212

313
This release is a bugfix release to fix issues related to installing Mycodo on the latest Raspberry Pi OS (Debian 12, Bookworm).

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Mycodo
33

44
Environmental Regulation System
55

6-
Latest version: 8.15.10
6+
Latest version: 8.15.11
77

88
Mycodo is open source software for the Raspberry Pi that couples inputs and outputs in interesting ways to sense and manipulate the environment.
99

mycodo/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
1414
from config_translations import TRANSLATIONS as T
1515

16-
MYCODO_VERSION = '8.15.10'
16+
MYCODO_VERSION = '8.15.11'
1717
ALEMBIC_VERSION = '16b28ef31b5b'
1818

1919
# FORCE UPGRADE MASTER

mycodo/mycodo_flask/routes_admin.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,22 @@ def install_dependencies(dependencies):
178178
for each_dep in dependencies:
179179
if each_dep[2] == 'bash-commands':
180180
for each_command in each_dep[1]:
181-
command = "{cmd} | ts '[%Y-%m-%d %H:%M:%S]' >> {log} 2>&1".format(
182-
cmd=each_command,
183-
log=DEPENDENCY_LOG_FILE)
184-
cmd_out, cmd_err, cmd_status = cmd_output(
185-
command, timeout=600, cwd="/tmp")
186-
logger.info("Command returned: out: {}, error: {}, status: {}".format(
187-
cmd_out, cmd_err, cmd_status))
181+
try:
182+
with open(DEPENDENCY_LOG_FILE, 'a') as f:
183+
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
184+
f.write(f"\n[{now}] Executing command: {each_command}\n")
185+
186+
command = "{cmd} | ts '[%Y-%m-%d %H:%M:%S]' >> {log} 2>&1".format(
187+
cmd=each_command,
188+
log=DEPENDENCY_LOG_FILE)
189+
cmd_out, cmd_err, cmd_status = cmd_output(
190+
command, user='root', timeout=600, cwd="/tmp")
191+
192+
with open(DEPENDENCY_LOG_FILE, 'a') as f:
193+
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
194+
f.write(f"\n[{now}] Command returned: out: {cmd_out}, error: {cmd_err}, status: {cmd_status}\n")
195+
except:
196+
logger.exception("Executing command")
188197
else:
189198
cmd = "{pth}/mycodo/scripts/mycodo_wrapper install_dependency {dep}" \
190199
" | ts '[%Y-%m-%d %H:%M:%S]' >> {log} 2>&1".format(

mycodo/mycodo_flask/routes_dashboard.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# coding=utf-8
22
"""collection of Page endpoints."""
3+
import flask_login
34
import logging
45
import os
5-
6-
import flask_login
6+
import subprocess
77
from flask import redirect, render_template, request, url_for
88
from flask.blueprints import Blueprint
99
from sqlalchemy import and_
1010

11+
from mycodo.config import INSTALL_DIRECTORY
1112
from mycodo.config import PATH_HTML_USER
1213
from mycodo.databases.models import (PID, Camera, Conditional, Conversion,
1314
CustomController, Dashboard,
@@ -125,7 +126,11 @@ def page_dashboard(dashboard_id):
125126

126127
# Widget
127128
elif form_base.widget_add.data:
128-
unmet_dependencies = utils_dashboard.widget_add(form_base, request.form)
129+
unmet_dependencies, reload_flask = utils_dashboard.widget_add(form_base, request.form)
130+
if not unmet_dependencies and reload_flask:
131+
return redirect(url_for(
132+
'routes_dashboard.restart_flask_auto_advance_page',
133+
dashboard_id=this_dashboard.unique_id))
129134
elif form_base.widget_mod.data:
130135
utils_dashboard.widget_mod(form_base, request.form)
131136
elif form_base.widget_delete.data:
@@ -319,3 +324,17 @@ def page_dashboard(dashboard_id):
319324
form_base=form_base,
320325
form_dashboard=form_dashboard,
321326
widget=widget)
327+
328+
329+
@blueprint.route('/reload_flask/<dashboard_id>')
330+
@flask_login.login_required
331+
def restart_flask_auto_advance_page(dashboard_id=""):
332+
"""Wait then automatically load next page"""
333+
logger.info("Reloading frontend in 5 seconds")
334+
335+
cmd = f"sleep 5 && {INSTALL_DIRECTORY}/mycodo/scripts/mycodo_wrapper frontend_reload 2>&1"
336+
subprocess.Popen(cmd, shell=True)
337+
logger.info("Rendering wait page")
338+
339+
return render_template('pages/wait_and_autoload.html',
340+
dashboard_id=dashboard_id)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% extends "layout.html" %}
2+
3+
{% set dashboard_dict = dict() %}
4+
5+
{% block title %} - Please Wait 10 Seconds{% endblock %}
6+
7+
{% block head %}
8+
<meta http-equiv="refresh" content="10;url=/dashboard/{{dashboard_id}}" />
9+
{% endblock %}
10+
11+
{% block body %}
12+
<!-- Route: /dashboard -->
13+
<div class="container">
14+
{% include 'flash_messages.html' %}
15+
</div>
16+
17+
<div class="container-fluid" style="text-align: center">
18+
To add this Widget, the Frontend needs to reload. Please wait for the frontend to reload. You will be automatically redirected after 10 seconds.
19+
</div>
20+
21+
{% endblock %}

mycodo/mycodo_flask/utils/utils_dashboard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ def widget_add(form_base, request_form):
157157
controller=TRANSLATIONS['widget']['title'])
158158
error = []
159159

160+
reload_flask = False
161+
160162
dict_widgets = parse_widget_information()
161163

162164
if form_base.widget_type.data:
@@ -230,9 +232,7 @@ def dict_has_value(key):
230232
# It has already handled its first request, any changes will not be applied consistently.
231233
# Make sure all imports, decorators, functions, etc. needed to set up the application are done before running it.
232234
if Widget.query.filter(Widget.graph_type == widget_name).count() == 1:
233-
cmd = f"{INSTALL_DIRECTORY}/mycodo/scripts/mycodo_wrapper frontend_reload 2>&1"
234-
init = subprocess.Popen(cmd, shell=True)
235-
init.wait()
235+
reload_flask = True
236236

237237
if not current_app.config['TESTING']:
238238
# Refresh widget settings
@@ -252,7 +252,7 @@ def dict_has_value(key):
252252
for each_error in error:
253253
flash(each_error, "error")
254254

255-
return dep_unmet
255+
return dep_unmet, reload_flask
256256

257257

258258
def widget_mod(form_base, request_form):

0 commit comments

Comments
 (0)