Skip to content

Commit

Permalink
Fix KeyError if missing options when saving Input, add 'tail dmesg' t…
Browse files Browse the repository at this point in the history
…o System Information page, update Werkzeug and distro
  • Loading branch information
kizniche committed Apr 3, 2020
1 parent bae25d1 commit 72790a9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
- Fix PID Widget preventing graph custom colors from being editable
- Fix graph Widget custom color issues ([#760](https://github.com/kizniche/mycodo/issues/760))
- Fix PWM Trigger Functions reacting to 0 % duty cycle being set ([#761](https://github.com/kizniche/mycodo/issues/761))
- Fix KeyError if missing options when saving Input

### Features

- Add 'tail dmesg' to System Information page

### Miscellaneous

- Update Werkzeug to 1.0.0 ([#742](https://github.com/kizniche/mycodo/issues/742)), Flask-RESTX to 0.2.0, alembic to 1.4.2, pyro5 to 5.8, and SQLAlchemy to 1.3.15
- Update Werkzeug to 1.0.1 ([#742](https://github.com/kizniche/mycodo/issues/742)), Flask-RESTX to 0.2.0, alembic to 1.4.2, pyro5 to 5.8, SQLAlchemy to 1.3.15, distro to 1.5.0,


## 8.4.0 (2020-03-23)
Expand Down
4 changes: 2 additions & 2 deletions install/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ alembic==1.4.2
argparse==1.4.0
bcrypt==3.1.7
daemonize==2.5.0
distro==1.4.0
distro==1.5.0
filelock==3.0.12
Flask==1.1.1
Flask_Accept==0.0.6
Expand All @@ -25,5 +25,5 @@ pyserial
python-dateutil==2.8.1
requests
SQLAlchemy==1.3.15
Werkzeug==1.0.0
Werkzeug==1.0.1
WTForms==2.2.1
9 changes: 9 additions & 0 deletions mycodo/mycodo_flask/routes_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,7 @@ def page_info():
frontend_pid = None
pstree_frontend_output = None
top_frontend_output = None
dmesg_output = None

uptime = subprocess.Popen(
"uptime", stdout=subprocess.PIPE, shell=True)
Expand Down Expand Up @@ -978,6 +979,13 @@ def page_info():
if free_output:
free_output = free_output.decode("latin1")

dmesg = subprocess.Popen(
"dmesg | tail -n 20", stdout=subprocess.PIPE, shell=True)
(dmesg_output, _) = dmesg.communicate()
dmesg.wait()
if dmesg_output:
dmesg_output = dmesg_output.decode("latin1")

ifconfig = subprocess.Popen(
"ifconfig -a", stdout=subprocess.PIPE, shell=True)
(ifconfig_output, _) = ifconfig.communicate()
Expand Down Expand Up @@ -1028,6 +1036,7 @@ def page_info():
database_version=database_version,
correct_database_version=correct_database_version,
df=df_output,
dmesg_output=dmesg_output,
free=free_output,
frontend_pid=frontend_pid,
i2c_devices_sorted=i2c_devices_sorted,
Expand Down
9 changes: 9 additions & 0 deletions mycodo/mycodo_flask/templates/pages/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
</div>
</div>

<div style="padding-bottom: 1.5em">
<div style="padding-bottom: 0.5em">
Diagnostic Messages: dmesg | tail -n 20
</div>
<div>
<pre style="padding: 0.5em; border: 1px solid Black;">{{dmesg_output}}</pre>
</div>
</div>

<div style="padding-bottom: 1.5em">
<div style="padding-bottom: 0.5em">
Network: ifconfig -a
Expand Down
18 changes: 12 additions & 6 deletions mycodo/mycodo_flask/utils/utils_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,12 +626,18 @@ def input_activate(form_mod):
#
if 'custom_options' in dict_inputs[input_dev.device]:
for each_option in dict_inputs[input_dev.device]['custom_options']:
value = custom_options_values_inputs[input_dev.unique_id][each_option['id']]
if ('required' in each_option and
each_option['required'] and
not value):
error.append("{} is required to be set".format(
each_option['name']))
if each_option['id'] not in custom_options_values_inputs[input_dev.unique_id]:
if ('required' in each_option and each_option['required']):
error.append("{} not found and is required to be set. "
"Set option and save Input.".format(
each_option['name']))
else:
value = custom_options_values_inputs[input_dev.unique_id][each_option['id']]
if ('required' in each_option and
each_option['required'] and
not value):
error.append("{} is required to be set".format(
each_option['name']))

#
# Input-specific checks
Expand Down

0 comments on commit 72790a9

Please sign in to comment.