Skip to content

Commit

Permalink
fix github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Stolyarov committed Jan 19, 2024
1 parent 6758885 commit 69b33fe
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/python-flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.10, 3.11, 3.12]
python-version: ['3.10', 3.11, 3.12]

steps:
- uses: actions/checkout@v2
Expand All @@ -23,6 +23,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install pytest-custom_exit_code
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
Expand Down
2 changes: 1 addition & 1 deletion read_el_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from typing import Any, Final, Self

try:
from pyModbusTCP import client, utils
from pyModbusTCP import client

except ImportError:
print(
Expand Down
3 changes: 2 additions & 1 deletion read_el_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ def main() -> None:
):
switch_value: bool = bool(
_read_input_registers(
modbus_client=modbus_client, address=register.value, count=1
modbus_client=modbus_client, address=register.value,
count=1
)[0]
)

Expand Down
65 changes: 36 additions & 29 deletions run_el_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ def _maintenance_on(
Turn Maintenance mode on.
"""
if initial_state is State.IDLE:
print(f'Turning Maintenance mode on...')
print('Turning Maintenance mode on...')

_toggle_maintenance(modbus_client=modbus_client, enable=True)

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


def _check_refilling_state(
modbus_client: client.ModbusClient, expected_refilling_state: RefillingState
modbus_client: client.ModbusClient,
expected_refilling_state: RefillingState
) -> None:
"""
Check specific refilling state.
Expand Down Expand Up @@ -875,8 +876,8 @@ def _perform_draining(modbus_client: client.ModbusClient) -> None:
)

print(
f'\n=================================================================\n'
f'============================ DRAINING ===========================\n\n'
'\n=================================================================\n'
'============================ DRAINING ===========================\n\n'
)
_wait_confirmation(
prompt=(
Expand All @@ -898,8 +899,8 @@ def _perform_flushing(modbus_client: client.ModbusClient) -> None:
Flushing procedure with required checks.
"""
print(
f'\n=================================================================\n'
f'============================ FLUSHING ===========================\n\n'
'\n=================================================================\n'
'============================ FLUSHING ===========================\n\n'
)

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

Expand Down Expand Up @@ -965,8 +967,8 @@ def _perform_refilling(
)

print(
f'\n=================================================================\n'
f'=========================== REFILLING ===========================\n\n'
'\n=================================================================\n'
'=========================== REFILLING ===========================\n\n'
)

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

_print_yellow(
text=(
f'Now waiting until water is mixed with pump, this process will'
f' be monitored automatically...'
'Now waiting until water is mixed with pump, this process will be'
' monitored automatically...'
)
)

Expand Down Expand Up @@ -1110,7 +1112,9 @@ def _wait_electrolyte_level(

while time.time() < wait_until:
if (
electrolyte_level := _electrolyte_level(modbus_client=modbus_client)
electrolyte_level := _electrolyte_level(
modbus_client=modbus_client
)
) is expected_level:
break

Expand Down Expand Up @@ -1195,8 +1199,8 @@ def _check_water_pipe_connection(
else:
_print_yellow(
text=(
f'Water inlet pressure {actual_water_inlet_pressure} is not'
f' in allowed bounds ({min_pressure}, {max_pressure})'
f'Water inlet pressure {actual_water_inlet_pressure} is'
f' not in allowed bounds ({min_pressure}, {max_pressure})'
)
)

Expand Down Expand Up @@ -1233,8 +1237,8 @@ def _check_water_pipe_connection(

_wait_confirmation(
prompt=(
f'Problems with water pipe detected.\nPlease double check water'
f' pipe, type {INPUT_CONFIRMATION} and press Enter when'
f'Problems with water pipe detected.\nPlease double check'
f' water pipe, type {INPUT_CONFIRMATION} and press Enter when'
f' ready:\n'
)
)
Expand Down Expand Up @@ -1285,8 +1289,9 @@ def _run_maintenance_21(

case _:
raise MaintenanceModeException(
f'Got unexpected refilling state {actual_refilling_state.name},'
f' please contact Enapter customer support'
f'Got unexpected refilling state'
f' {actual_refilling_state.name}, please contact Enapter'
f' customer support'
)

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

active_errors: str = (
', '.join(_decode_errors(modbus_client=modbus_client)) or
'No errors'
', '.join(
_decode_errors(modbus_client=modbus_client)
) or 'No errors'
)

active_warnings: str = (
', '.join(_decode_warnings(modbus_client=modbus_client)) or
'No warnings'
', '.join(
_decode_warnings(modbus_client=modbus_client)
) or 'No warnings'
)

_print_red(
Expand Down
4 changes: 2 additions & 2 deletions write_el_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from typing import Any, Final, Self

try:
from pyModbusTCP import client, utils
from pyModbusTCP import client

except ImportError:
print(
Expand Down Expand Up @@ -113,7 +113,7 @@ def main() -> None:
)
) is None
):
print(f'Waiting for Modbus initialization...')
print('Waiting for Modbus initialization...')

time.sleep(1)

Expand Down

0 comments on commit 69b33fe

Please sign in to comment.