Skip to content

Commit 4916919

Browse files
authored
fix github actions (#4)
1 parent 6758885 commit 4916919

File tree

6 files changed

+54
-42
lines changed

6 files changed

+54
-42
lines changed

.github/workflows/python-flake8.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
python-version: [3.10, 3.11, 3.12]
15+
python-version: ['3.10', 3.11, 3.12]
1616

1717
steps:
1818
- uses: actions/checkout@v2
@@ -23,6 +23,7 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
python -m pip install --upgrade pip
26+
pip install flake8
2627
pip install pytest-custom_exit_code
2728
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
2829
- name: Lint with flake8

read_el_errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from typing import Any, Final, Self
1818

1919
try:
20-
from pyModbusTCP import client, utils
20+
from pyModbusTCP import client
2121

2222
except ImportError:
2323
print(
@@ -38,8 +38,8 @@
3838

3939
class Error(IntEnum):
4040
"""
41-
Values for errors input register (832). Names may be used for human-readable
42-
description.
41+
Values for errors input register (832). Names may be used for
42+
human-readable description.
4343
"""
4444

4545
UNKNOWN = -1

read_el_params.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,8 @@ def main() -> None:
204204
):
205205
switch_value: bool = bool(
206206
_read_input_registers(
207-
modbus_client=modbus_client, address=register.value, count=1
207+
modbus_client=modbus_client, address=register.value,
208+
count=1
208209
)[0]
209210
)
210211

run_el_maintenance.py

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ def _maintenance_on(
771771
Turn Maintenance mode on.
772772
"""
773773
if initial_state is State.IDLE:
774-
print(f'Turning Maintenance mode on...')
774+
print('Turning Maintenance mode on...')
775775

776776
_toggle_maintenance(modbus_client=modbus_client, enable=True)
777777

@@ -794,7 +794,7 @@ def _maintenance_off(modbus_client: client.ModbusClient) -> None:
794794
"""
795795
Turn Maintenance mode off.
796796
"""
797-
print(f'Turning Maintenance mode off...')
797+
print('Turning Maintenance mode off...')
798798

799799
_toggle_maintenance(modbus_client=modbus_client, enable=False)
800800

@@ -808,7 +808,8 @@ def _maintenance_off(modbus_client: client.ModbusClient) -> None:
808808

809809

810810
def _check_refilling_state(
811-
modbus_client: client.ModbusClient, expected_refilling_state: RefillingState
811+
modbus_client: client.ModbusClient,
812+
expected_refilling_state: RefillingState
812813
) -> None:
813814
"""
814815
Check specific refilling state.
@@ -875,8 +876,8 @@ def _perform_draining(modbus_client: client.ModbusClient) -> None:
875876
)
876877

877878
print(
878-
f'\n=================================================================\n'
879-
f'============================ DRAINING ===========================\n\n'
879+
'\n=================================================================\n'
880+
'============================ DRAINING ===========================\n\n'
880881
)
881882
_wait_confirmation(
882883
prompt=(
@@ -898,8 +899,8 @@ def _perform_flushing(modbus_client: client.ModbusClient) -> None:
898899
Flushing procedure with required checks.
899900
"""
900901
print(
901-
f'\n=================================================================\n'
902-
f'============================ FLUSHING ===========================\n\n'
902+
'\n=================================================================\n'
903+
'============================ FLUSHING ===========================\n\n'
903904
)
904905

905906
_check_refilling_state(
@@ -925,7 +926,8 @@ def _perform_flushing(modbus_client: client.ModbusClient) -> None:
925926
f'\nNow electrolyser will be automatically refilled with'
926927
f' water.\nCurrent electrolyte level will be reported every'
927928
f' {ELECTROLYTE_PRESENCE_CHECK_TIMEOUT} seconds until flushing is'
928-
f' complete.\nType {INPUT_CONFIRMATION} and press Enter to proceed:'
929+
f' complete.\nType {INPUT_CONFIRMATION} and press Enter to'
930+
f' proceed:'
929931
)
930932
)
931933

@@ -940,8 +942,8 @@ def _perform_flushing(modbus_client: client.ModbusClient) -> None:
940942

941943
_print_yellow(
942944
text=(
943-
f'Now waiting until water is mixed with pump, this process will'
944-
f' be monitored automatically...'
945+
'Now waiting until water is mixed with pump, this process will'
946+
' be monitored automatically...'
945947
)
946948
)
947949

@@ -965,8 +967,8 @@ def _perform_refilling(
965967
)
966968

967969
print(
968-
f'\n=================================================================\n'
969-
f'=========================== REFILLING ===========================\n\n'
970+
'\n=================================================================\n'
971+
'=========================== REFILLING ===========================\n\n'
970972
)
971973

972974
refill_to_level: ElectrolyteLevel = (
@@ -1081,8 +1083,8 @@ def _finish_refilling(modbus_client: client.ModbusClient) -> None:
10811083

10821084
_print_yellow(
10831085
text=(
1084-
f'Now waiting until water is mixed with pump, this process will'
1085-
f' be monitored automatically...'
1086+
'Now waiting until water is mixed with pump, this process will be'
1087+
' monitored automatically...'
10861088
)
10871089
)
10881090

@@ -1110,7 +1112,9 @@ def _wait_electrolyte_level(
11101112

11111113
while time.time() < wait_until:
11121114
if (
1113-
electrolyte_level := _electrolyte_level(modbus_client=modbus_client)
1115+
electrolyte_level := _electrolyte_level(
1116+
modbus_client=modbus_client
1117+
)
11141118
) is expected_level:
11151119
break
11161120

@@ -1195,8 +1199,8 @@ def _check_water_pipe_connection(
11951199
else:
11961200
_print_yellow(
11971201
text=(
1198-
f'Water inlet pressure {actual_water_inlet_pressure} is not'
1199-
f' in allowed bounds ({min_pressure}, {max_pressure})'
1202+
f'Water inlet pressure {actual_water_inlet_pressure} is'
1203+
f' not in allowed bounds ({min_pressure}, {max_pressure})'
12001204
)
12011205
)
12021206

@@ -1233,8 +1237,8 @@ def _check_water_pipe_connection(
12331237

12341238
_wait_confirmation(
12351239
prompt=(
1236-
f'Problems with water pipe detected.\nPlease double check water'
1237-
f' pipe, type {INPUT_CONFIRMATION} and press Enter when'
1240+
f'Problems with water pipe detected.\nPlease double check'
1241+
f' water pipe, type {INPUT_CONFIRMATION} and press Enter when'
12381242
f' ready:\n'
12391243
)
12401244
)
@@ -1285,8 +1289,9 @@ def _run_maintenance_21(
12851289

12861290
case _:
12871291
raise MaintenanceModeException(
1288-
f'Got unexpected refilling state {actual_refilling_state.name},'
1289-
f' please contact Enapter customer support'
1292+
f'Got unexpected refilling state'
1293+
f' {actual_refilling_state.name}, please contact Enapter'
1294+
f' customer support'
12901295
)
12911296

12921297
if draining_required:
@@ -1336,8 +1341,9 @@ def _run_maintenance_4x(
13361341

13371342
case _:
13381343
raise MaintenanceModeException(
1339-
f'Got unexpected refilling state {actual_refilling_state.name},'
1340-
f' please contact Enapter customer support'
1344+
f'Got unexpected refilling state'
1345+
f' {actual_refilling_state.name}, please contact Enapter'
1346+
f' customer support'
13411347
)
13421348

13431349
if draining_required:
@@ -1456,13 +1462,13 @@ def main() -> None:
14561462
'WARNING! Please read carefully!\nThis script turns'
14571463
f' Maintenance mode on.\nMaintenance mode requires manual'
14581464
f' actions with electrolyser such as electrolyte draining,'
1459-
f' flushing (for EL4.x) and refilling.\nIf you fill electrolyte'
1460-
f' for the first time, only refilling is required.\nIf at some'
1461-
f' step electrolyte level is reported incorrectly, it may'
1462-
f' indicate hardware problems.\nIn this case terminate script'
1463-
f' with Ctrl+C and contact Enapter customer support.\nScript'
1464-
f' will be terminated anyway if draining/refilling is not'
1465-
f' complete during'
1465+
f' flushing (for EL4.x) and refilling.\nIf you fill'
1466+
f' electrolyte for the first time, only refilling is required.'
1467+
f'\nIf at some step electrolyte level is reported incorrectly,'
1468+
f' it may indicate hardware problems.\nIn this case terminate'
1469+
f' script with Ctrl+C and contact Enapter customer support.\n'
1470+
f'Script will be terminated anyway if draining/refilling is'
1471+
f' not complete during'
14661472
f' {DRAINING_TIMEOUT // 60}/{REFILLING_TIMEOUT // 60} minutes'
14671473
f' correspondingly.\nType {INPUT_CONFIRMATION} and press Enter'
14681474
f' if you really want to continue. Press Ctrl+С or Enter to'
@@ -1514,13 +1520,15 @@ def main() -> None:
15141520
print(f'Modbus exception: {modbus_client.last_except_as_txt}')
15151521

15161522
active_errors: str = (
1517-
', '.join(_decode_errors(modbus_client=modbus_client)) or
1518-
'No errors'
1523+
', '.join(
1524+
_decode_errors(modbus_client=modbus_client)
1525+
) or 'No errors'
15191526
)
15201527

15211528
active_warnings: str = (
1522-
', '.join(_decode_warnings(modbus_client=modbus_client)) or
1523-
'No warnings'
1529+
', '.join(
1530+
_decode_warnings(modbus_client=modbus_client)
1531+
) or 'No warnings'
15241532
)
15251533

15261534
_print_red(

write_el_reboot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from typing import Any, Final, Self
1919

2020
try:
21-
from pyModbusTCP import client, utils
21+
from pyModbusTCP import client
2222

2323
except ImportError:
2424
print(
@@ -113,7 +113,7 @@ def main() -> None:
113113
)
114114
) is None
115115
):
116-
print(f'Waiting for Modbus initialization...')
116+
print('Waiting for Modbus initialization...')
117117

118118
time.sleep(1)
119119

write_el_syslog_skip_priority.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def _write_multiple_registers(
142142
"""
143143
Write over 16 bits register.
144144
"""
145-
modbus_client.write_multiple_registers(regs_addr=address, regs_value=values)
145+
modbus_client.write_multiple_registers(
146+
regs_addr=address, regs_value=values
147+
)
146148

147149
time.sleep(REGISTER_WRITE_TIMEOUT)
148150

0 commit comments

Comments
 (0)