Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HEV - High Energy Ventilator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
HEV - High Energy Ventilator
Commits
81131dd5
Commit
81131dd5
authored
Jul 08, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: check startup_config keys against startup_config_default and ignore mismatched keys
parent
17a76c5d
Pipeline
#1916
failed with stages
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
862 additions
and
110 deletions
+862
-110
.pre-commit-config.yaml
.pre-commit-config.yaml
+168
-27
.pylint.cfg
.pylint.cfg
+588
-0
ui_layout.py
NativeUI/ui_layout.py
+28
-25
ui_widgets.py
NativeUI/ui_widgets.py
+60
-42
measurements_widget.py
NativeUI/widget_library/measurements_widget.py
+18
-16
No files found.
.pre-commit-config.yaml
View file @
81131dd5
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude
:
^[\S]*{{cookiecutter[\S]*
default_language_version
:
python
:
python3.8
fail_fast
:
false
default_stages
:
[
commit
,
merge-commit
,
push
]
repos
:
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
rev
:
v3.1.0
hooks
:
-
id
:
trailing-whitespace
-
id
:
end-of-file-fixer
-
id
:
check-yaml
-
id
:
check-added-large-files
-
id
:
check-json
# - id: pretty-format-json
-
id
:
requirements-txt-fixer
-
repo
:
https://github.com/psf/black
rev
:
19.3b0
hooks
:
-
id
:
black
language_version
:
python3.7
# - repo: https://github.com/timothycrosley/isort
# rev: 5.0.8
# hooks:
# - id: isort
-
repo
:
https://github.com/pycqa/pylint
rev
:
pylint-2.6.0
hooks
:
-
id
:
pylint
args
:
-
--rcfile=pylint.cfg
# == LOGISTICS =============================================================
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
rev
:
v4.0.1
hooks
:
-
id
:
no-commit-to-branch
stages
:
[
commit
]
-
id
:
check-added-large-files
-
id
:
check-ast
-
id
:
check-builtin-literals
-
id
:
check-case-conflict
-
id
:
check-docstring-first
-
id
:
check-json
# - id: check-shebang-scripts-are-executable
-
id
:
check-merge-conflict
-
id
:
check-symlinks
-
id
:
check-toml
-
id
:
check-vcs-permalinks
-
id
:
check-xml
-
id
:
check-yaml
-
id
:
debug-statements
-
id
:
destroyed-symlinks
# - id: detect-private-key
-
id
:
end-of-file-fixer
-
id
:
file-contents-sorter
-
id
:
fix-byte-order-marker
-
id
:
fix-encoding-pragma
-
id
:
forbid-new-submodules
-
id
:
mixed-line-ending
-
id
:
name-tests-test
-
id
:
pretty-format-json
args
:
[
--autofix
,
--indent
,
"
2"
]
-
id
:
requirements-txt-fixer
-
id
:
sort-simple-yaml
-
id
:
trailing-whitespace
-
repo
:
https://github.com/commitizen-tools/commitizen
rev
:
'
v2.17.12'
hooks
:
-
id
:
commitizen
stages
:
[
commit-msg
]
# == DOCUMENTATION =========================================================
# blacken docs
-
repo
:
https://github.com/asottile/blacken-docs
rev
:
v1.10.0
hooks
:
-
id
:
blacken-docs
# Markdown Formatter
-
repo
:
https://github.com/Lucas-C/pre-commit-hooks-markup
rev
:
v1.0.1
hooks
:
-
id
:
rst-linter
# Markdown TOC
-
repo
:
https://github.com/frnmst/md-toc
rev
:
'
8.0.0'
hooks
:
-
id
:
md-toc
# latex
-
repo
:
https://github.com/jonasbb/pre-commit-latex-hooks
rev
:
'
v1.2.2'
hooks
:
-
id
:
csquotes
-
id
:
cleveref-capitalization
-
id
:
tilde-cite
-
id
:
no-space-in-cite
-
id
:
consistent-spelling
# - id: ensure-labels-for-sections
-
id
:
cispa-syssec-forbidden-words
# Forbidden words for CISPA SysSec
# == YAML ==================================================================
-
repo
:
https://github.com/adrienverge/yamllint
rev
:
'
v1.26.1'
hooks
:
-
id
:
yamllint
exclude
:
.gitlab-ci.yml
# == PYTHON ================================================================
# black
-
repo
:
https://github.com/psf/black
rev
:
21.6b0
hooks
:
-
id
:
black
language_version
:
python3.8
# blacken ipynb files
-
repo
:
https://github.com/dfm/black_nbconvert
rev
:
'
v0.2.0'
hooks
:
-
id
:
black_nbconvert
# remove unused imports
-
repo
:
https://github.com/hadialqattan/pycln
rev
:
'
0.0.4'
hooks
:
-
id
:
pycln
# sort imports
# - repo: https://github.com/timothycrosley/isort
# rev: 5.9.2
# hooks:
# - id: isort
# args: [
# --profile black,
# ]
# static typing
-
repo
:
https://github.com/pre-commit/mirrors-mypy
rev
:
v0.910
hooks
:
-
id
:
mypy
# common errors
-
repo
:
https://github.com/pre-commit/pygrep-hooks
rev
:
v1.9.0
hooks
:
-
id
:
python-check-blanket-noqa
-
id
:
python-check-blanket-type-ignore
-
id
:
python-check-mock-methods
-
id
:
python-no-eval
-
id
:
python-no-log-warn
-
id
:
python-use-type-annotations
-
id
:
rst-backticks
-
id
:
rst-directive-colons
-
id
:
rst-inline-touching-normal
-
id
:
text-unicode-replacement-char
# numpydoc formatting for docstrings
-
repo
:
https://github.com/Carreau/velin
rev
:
'
0.0.11'
hooks
:
-
id
:
velin
# python safety
-
repo
:
https://github.com/Lucas-C/pre-commit-hooks-safety
rev
:
v1.2.1
hooks
:
-
id
:
python-safety-dependencies-check
# check package manifests
# - repo: https://github.com/mgedmin/check-manifest
# rev: '0.46'
# hooks:
# - id: check-manifest
# pylint
-
repo
:
https://github.com/PyCQA/pylint
rev
:
v2.9.3
hooks
:
-
id
:
pylint
log_file
:
logs/pylint.log
args
:
-
--rcfile=.pylint.cfg
# compile requirements
-
repo
:
https://github.com/jazzband/pip-tools
rev
:
'
6.2.0'
hooks
:
-
id
:
pip-compile
stages
:
[
push
,
merge-commit
]
# == BASH ==================================================================
-
repo
:
https://github.com/lovesegfault/beautysh
rev
:
v6.1.0
hooks
:
-
id
:
beautysh
# == DOCKER ================================================================
-
repo
:
https://github.com/pryorda/dockerfilelint-precommit-hooks
rev
:
v0.1.0
hooks
:
-
id
:
dockerfilelint
.pylint.cfg
0 → 100644
View file @
81131dd5
This diff is collapsed.
Click to expand it.
NativeUI/ui_layout.py
View file @
81131dd5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
ui_layout.py
...
...
@@ -14,16 +15,17 @@ __maintainer__ = "Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2
import
QtWidgets
,
QtCore
,
QtGui
# from PySide2.QtGui import QFont, QSizePolicy
from
widget_library.switchable_stack_widget
import
SwitchableStackWidget
import
json
import
logging
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
widget_library.localised_base_widgets
import
(
LocalisedQStackedWidget
,
LocalisedQWidget
,
)
import
logging
# from PySide2.QtGui import QFont, QSizePolicy
from
widget_library.switchable_stack_widget
import
SwitchableStackWidget
# from widget_library.page_stack_widget import PageStackWidget
...
...
@@ -119,7 +121,7 @@ class Layout:
# Add buttons
h_button_layout
.
addWidget
(
self
.
NativeUI
.
widgets
.
startup_backButton
)
#h_button_layout.addWidget(self.NativeUI.widgets.startup_skipButton)
#
h_button_layout.addWidget(self.NativeUI.widgets.startup_skipButton)
h_button_layout
.
addWidget
(
self
.
NativeUI
.
widgets
.
startup_nextButton
)
# Put the layouts together
...
...
@@ -129,8 +131,8 @@ class Layout:
v_layout
.
addLayout
(
h_button_layout
)
# Ensure that next and skip buttons are disabled by default.
#self.NativeUI.widgets.skipButton.setEnabled(False)
#self.NativeUI.widgets.nextButton.setEnabled(False)
#
self.NativeUI.widgets.skipButton.setEnabled(False)
#
self.NativeUI.widgets.nextButton.setEnabled(False)
return
v_layout
...
...
@@ -146,7 +148,7 @@ class Layout:
self
.
widgets
.
alarm_control_startup
,
]
for
i
,
widget
in
enumerate
(
top_bar_widgets
):
if
i
is
not
0
:
if
i
!=
0
:
top_bar_layout
.
addStretch
()
top_bar_layout
.
addWidget
(
widget
)
widget
.
setFont
(
self
.
NativeUI
.
text_font
)
...
...
@@ -854,8 +856,8 @@ class Layout:
widg
=
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
if
setting
[
0
]
in
modeDict
[
"radioSettings"
]:
stack
.
addWidget
(
widg
)
#widg.signalling_spin.setFont(self.NativeUI.value_font)
#widg.label.setFont(self.NativeUI.text_font)
#
widg.signalling_spin.setFont(self.NativeUI.value_font)
#
widg.label.setFont(self.NativeUI.text_font)
if
"IE Ratio"
in
widg
.
label_text
:
stack
.
setCurrentWidget
(
widg
)
else
:
...
...
@@ -912,25 +914,26 @@ class Layout:
vtlayout3
=
QtWidgets
.
QVBoxLayout
()
labelLayout
=
QtWidgets
.
QHBoxLayout
()
for
labelname
in
[
'Low Limit'
,
'Set Point'
,
'High Limit'
]:
for
labelname
in
[
"Low Limit"
,
"Set Point"
,
"High Limit"
]:
labelWidg
=
QtWidgets
.
QLabel
(
labelname
)
labelWidg
.
setFont
(
self
.
NativeUI
.
text_font
)
labelWidg
.
setStyleSheet
(
"color: "
+
self
.
NativeUI
.
colors
[
"label_foreground"
]
.
name
())
labelWidg
.
setStyleSheet
(
"color: "
+
self
.
NativeUI
.
colors
[
"label_foreground"
]
.
name
()
)
labelWidg
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
labelLayout
.
addWidget
(
labelWidg
)
for
setting
in
clinicalDict
[
"settings"
]:
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
hlayout
=
QtWidgets
.
QHBoxLayout
()
if
'VTI'
in
setting
[
0
][
0
]:
vtlayout1
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
)
)
if
"VTI"
in
setting
[
0
][
0
]:
vtlayout1
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
vtlayout3
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
elif
"VTE"
in
setting
[
0
][
0
]:
vtlayout1
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
vtlayout2
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_set"
))
vtlayout3
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
elif
'VTE'
in
setting
[
0
][
0
]:
vtlayout1
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
)
)
vtlayout2
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_set"
)
)
vtlayout3
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
)
)
elif
len
(
setting
)
==
2
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
hlayout
.
addWidget
(
QtWidgets
.
QWidget
())
...
...
@@ -938,9 +941,7 @@ class Layout:
doubleLayout
.
addLayout
(
hlayout
)
elif
len
(
setting
)
==
3
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_set"
)
)
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_set"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
tripleLayout
.
addLayout
(
hlayout
)
elif
len
(
setting
)
==
1
:
...
...
@@ -952,9 +953,11 @@ class Layout:
vthlayout
.
addLayout
(
vtlayout2
)
vthlayout
.
addLayout
(
vtlayout3
)
thresh_label
=
QtWidgets
.
QLabel
(
'Threshold'
)
thresh_label
=
QtWidgets
.
QLabel
(
"Threshold"
)
thresh_label
.
setFont
(
self
.
NativeUI
.
text_font
)
thresh_label
.
setStyleSheet
(
"color: "
+
self
.
NativeUI
.
colors
[
"label_foreground"
]
.
name
())
thresh_label
.
setStyleSheet
(
"color: "
+
self
.
NativeUI
.
colors
[
"label_foreground"
]
.
name
()
)
thresh_label
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
vlayout
.
addWidget
(
thresh_label
)
...
...
NativeUI/ui_widgets.py
View file @
81131dd5
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ui_widgets.py
...
...
@@ -13,42 +15,51 @@ __maintainer__ = "Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
from
widget_library.localised_base_widgets
import
(
LocalisedQStackedWidget
,
LocalisedQRadioButton
,
LocalisedQPushButton
,
LocalisedQWidget
,
LocalisedQLabel
,
)
from
PySide2.QtWidgets
import
QWidget
,
QButtonGroup
import
json
import
logging
import
os
import
shutil
from
alarm_widgets.alarm_handler
import
AlarmHandler
from
alarm_widgets.alarm_list
import
AlarmList
from
alarm_widgets.alarm_popup
import
AlarmPopup
from
alarm_widgets.alarm_table
import
AlarmTable
from
global_widgets.global_send_popup
import
SetConfirmPopup
from
global_widgets.global_spinbox
import
labelledSpin
from
global_widgets.global_typeval_popup
import
AbstractTypeValPopup
from
global_widgets.tab_hold_buttons
import
timerConfirmPopup
from
global_widgets.tab_modeswitch_button
import
TabModeswitchButton
from
global_widgets.global_spinbox
import
labelledSpin
from
global_widgets.global_send_popup
import
SetConfirmPopup
from
widget_library.localisation_button_widget
import
LocalisationButtonWidget
from
widget_library.startup_handler
import
StartupHandler
from
handler_library.maintenance_handler
import
MaintenanceHandler
from
widget_library.startup_calibration_widget
import
calibrationWidget
from
widget_library.ok_cancel_buttons_widget
import
(
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
,
)
from
widget_library.history_buttons_widget
import
HistoryButtonsWidget
from
widget_library.measurements_widget
import
(
NormalMeasurementsBlockWidget
,
ExpertMeasurementsBloackWidget
,
)
from
PySide2.QtWidgets
import
QButtonGroup
,
QWidget
from
widget_library.alarm_control_widget
import
AlarmControlWidget
from
widget_library.battery_display_widget
import
BatteryDisplayWidget
from
widget_library.chart_buttons_widget
import
ChartButtonsWidget
from
widget_library.history_buttons_widget
import
HistoryButtonsWidget
from
widget_library.info_display_widgets
import
(
VersionDisplayWidget
,
MaintenanceTimeDisplayWidget
,
UpdateTimeDisplayWidget
,
UptimeDisplayWidget
,
VersionDisplayWidget
,
)
from
widget_library.alarm_control_widget
import
AlarmControlWidget
from
widget_library.chart_buttons_widget
import
ChartButtonsWidget
from
widget_library.page_buttons_widget
import
PageButtonsWidget
,
PageButton
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
from
widget_library.localisation_button_widget
import
LocalisationButtonWidget
from
widget_library.localised_base_widgets
import
(
LocalisedQLabel
,
LocalisedQPushButton
,
LocalisedQRadioButton
,
LocalisedQStackedWidget
,
LocalisedQWidget
,
)
from
widget_library.measurements_widget
import
(
ExpertMeasurementsBloackWidget
,
NormalMeasurementsBlockWidget
,
)
from
widget_library.ok_cancel_buttons_widget
import
(
CancelButtonWidget
,
OkButtonWidget
,
OkSendButtonWidget
,
)
from
widget_library.page_buttons_widget
import
PageButton
,
PageButtonsWidget
from
widget_library.personal_display_widget
import
PersonalDisplayWidget
from
widget_library.plot_widget
import
(
ChartsPlotWidget
,
...
...
@@ -56,19 +67,11 @@ from widget_library.plot_widget import (
TimePlotsWidget
,
)
from
widget_library.spin_buttons_widget
import
SpinButton
from
widget_library.startup_calibration_widget
import
calibrationWidget
from
widget_library.startup_handler
import
StartupHandler
from
widget_library.ventilator_start_stop_buttons_widget
import
(
VentilatorStartStopButtonsWidget
,
)
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
from
global_widgets.global_typeval_popup
import
AbstractTypeValPopup
from
alarm_widgets.alarm_handler
import
AlarmHandler
from
alarm_widgets.alarm_list
import
AlarmList
from
alarm_widgets.alarm_popup
import
AlarmPopup
from
alarm_widgets.alarm_table
import
AlarmTable
import
json
import
os
import
shutil
import
logging
class
Widgets
:
...
...
@@ -101,6 +104,7 @@ class Widgets:
self
.
localisation_startup_button
,
]
# Import startup_config
if
not
os
.
path
.
isfile
(
"NativeUI/configs/startup_config.json"
):
logging
.
warning
(
"startup_config not found. If this is the first time using this "
...
...
@@ -112,13 +116,27 @@ class Widgets:
)
with
open
(
"NativeUI/configs/startup_config.json"
)
as
json_file
:
startupDict
=
json
.
load
(
json_file
)
with
open
(
"NativeUI/configs/startup_config_default.json"
)
as
json_file
:
startup_dict_default
=
json
.
load
(
json_file
)
for
key
,
procedureDict
in
startupDict
.
items
():
self
.
add_handled_widget
(
calibrationWidget
(
NativeUI
,
key
,
procedureDict
),
key
,
self
.
startup_handler
,
)
if
key
in
startup_dict_default
:
self
.
add_handled_widget
(
calibrationWidget
(
NativeUI
,
key
,
procedureDict
),
key
,
self
.
startup_handler
,
)
else
:
logging
.
warning
(
"Key
%
s in startup_config.json is not present in startup_config_default.json and will be ignored."
,
key
,
)
for
key
in
startup_dict_default
:
if
key
not
in
startupDict
:
logging
.
error
(
"Expected key
%
s is absent from startup_config.json."
,
key
)
# Import maintanence_config
if
not
os
.
path
.
isfile
(
"NativeUI/configs/maintenance_config.json"
):
logging
.
warning
(
"maintenance_config not found. If this is the first time using this "
...
...
NativeUI/widget_library/measurements_widget.py
View file @
81131dd5
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
measurements_widget.py
...
...
@@ -16,11 +17,11 @@ __maintainer__ = "Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Development"
import
logging
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
import
math
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
class
MeasurementsBlockWidget
(
QtWidgets
.
QWidget
):
"""
...
...
@@ -46,20 +47,21 @@ class MeasurementsBlockWidget(QtWidgets.QWidget):
# Create Muasurement widgets
self
.
widget_list
=
[]
for
measurement
in
measurements
:
if
len
(
measurement
)
>
2
:
self
.
widget_list
.
append
(
MeasurementWidget
(
NativeUI
,
measurement
[
0
],
# Label key
measurement
[
1
],
# Key
measurement
[
2
],
# Format
if
measurements
is
not
None
:
for
measurement
in
measurements
:
if
len
(
measurement
)
>
2
:
self
.
widget_list
.
append
(
MeasurementWidget
(
NativeUI
,
measurement
[
0
],
# Label key
measurement
[
1
],
# Key
measurement
[
2
],
# Format
)
)
else
:
self
.
widget_list
.
append
(
MeasurementWidget
(
NativeUI
,
measurement
[
0
],
measurement
[
1
])
)
)
else
:
self
.
widget_list
.
append
(
MeasurementWidget
(
NativeUI
,
measurement
[
0
],
measurement
[
1
])
)
# Compute max number of items per column
self
.
__grid_rows
=
int
(
len
(
self
.
widget_list
)
/
(
self
.
__grid_columns
))
...
...
@@ -260,7 +262,7 @@ class MeasurementWidget(QtWidgets.QWidget):
return
0
def
__format_value
(
self
,
number
):
if
self
.
format
is
"ratio"
:
if
self
.
format
==
"ratio"
:
n_digits
=
1
vals
=
number
.
as_integer_ratio
()
order_of_mag
=
math
.
floor
(
math
.
log
(
vals
[
0
],
10
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment