Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/python-script-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Python Script Checks

on:
workflow_dispatch:
pull_request:
branches: [ main, mf2025/main ]
paths:
- 'Scripts/**/*.py'

jobs:
python-script-checks:
name: Python ${{ matrix.python-version }} Syntax Check
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version:
- '3.11'
- '3.12'
- '3.13'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pylint gql websockets simconnect

- name: Run linter on the Scripts folder
run: pylint Scripts --disable=all --enable=F,E
2 changes: 1 addition & 1 deletion Scripts/Winwing/fbw_a32nx_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MfColour(StrEnum):

class MobiFlightClient:
def __init__(self, websocket_uri: str, max_retries: int = 3) -> None:
self.websocket: Optional[ws_client.WebSocketClientProtocol] = None
self.websocket: Optional[ws_client.ClientConnection] = None
self.connected: asyncio.Event = asyncio.Event()
self.websocket_uri: str = websocket_uri
self.retries: int = 0
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Winwing/fenix_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async def run_mobiflight_websocket_client(self):
# Break and stop for that CDU
break
else:
logging.error(f"Error on trying to connect to MobiFlight websocket interface for {self.id}. Will retry: {ex}")
logging.error(f"Error on trying to connect to MobiFlight websocket interface for {self.id}. Will retry: {invalid}")
except Exception as ex:
logging.error(f"Error on trying to connect to MobiFlight websocket interface for {self.id}. Will retry: {ex}")
self.websocket_connection = None
Expand Down
3 changes: 0 additions & 3 deletions Scripts/Winwing/fslabs_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@

async def fetch_fsl_mcdu():
"""Fetch MCDU data using a persistent HTTP connection, avoiding redundant updates."""
global last_mcdu_data
last_fetched_data = None

conn = http.client.HTTPConnection("localhost", 8080, timeout=1) # Persistent connection
Expand Down Expand Up @@ -80,8 +79,6 @@ async def fetch_fsl_mcdu():

async def run_fsl_http_client():
"""Measure the time it takes to send updates to MobiFlight."""
global mobi_websocket_connection

while True:
mobi_json = await data_queue.get()

Expand Down
46 changes: 1 addition & 45 deletions Scripts/Winwing/headwind_a33_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class MfColour(StrEnum):

class MobiFlightClient:
def __init__(self, websocket_uri: str, max_retries: int = 3) -> None:
self.websocket: Optional[ws_client.WebSocketClientProtocol] = None
self.websocket: Optional[ws_client.ClientConnection] = None
self.connected: asyncio.Event = asyncio.Event()
self.websocket_uri: str = websocket_uri
self.retries: int = 0
Expand Down Expand Up @@ -420,50 +420,6 @@ async def connect_to_mcdu(self):
await asyncio.sleep(5) # Wait before retry
return False

async def run(self):
"""Main processing loop"""
logging.info("Starting FlyByWire SimBridge client")
while True:
try:
# Wait for messages from the MCDU
if self.fbw_websocket is None:
if not await self.connect_to_mcdu():
logging.info("Max SimBridge attempts reached. Waiting for new attempts.")
await asyncio.sleep(
10
) # Wait longer between retries if we can't connect
continue

msg = await self.fbw_websocket.recv()

# Process any update messages
if msg.startswith("update:"):
data_json = json.loads(msg[msg.index(":") + 1:])

for side in ("left", "right"):
mobiflight = self.mobiflight.get(side)
mcdu_data = data_json.get(side)
if mobiflight is not None and mobiflight.is_connected():
# only update if there is new data to display
if (
mcdu_data is not None
and self.last_mcdu_data.get(side) != mcdu_data
):
self.last_mcdu_data[side] = mcdu_data
await mobiflight.send(create_mobi_json(mcdu_data))
elif mcdu_data is None:
self.last_mcdu_data[side] = None
# clear the display
await mobiflight.send(create_mobi_json(dict()))
else:
# make sure we get a refresh if we later connect
self.last_mcdu_data[side] = None

except Exception as e:
logging.error(f"Error processing MCDU data: {e}")
self.fbw_websocket = None
await asyncio.sleep(5)

async def request_update(self):
if self.fbw_websocket is not None:
await self.fbw_websocket.send("requestUpdate")
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Winwing/ifly_737_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
import asyncio
from typing import Dict, List, Optional, Union
from websockets.client import connect
from websockets.asyncio.client import connect
import mmap

# WebSocket URLs
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Winwing/maddogx_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def my_dispatch_proc(self, pData, cbData, pContext):

class MobiFlightClient:
def __init__(self, websocket_uri: str, max_retries: int = 3) -> None:
self.websocket: Optional[ws_client.WebSocketClientProtocol] = None
self.websocket: Optional[ws_client.ClientConnection] = None
self.connected: asyncio.Event = asyncio.Event()
self.websocket_uri: str = websocket_uri
self.retries: int = 0
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Winwing/pmdg_737_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def my_dispatch_proc(self, pData, cbData, pContext):

class MobiFlightClient:
def __init__(self, websocket_uri: str, max_retries: int = 3) -> None:
self.websocket: Optional[ws_client.WebSocketClientProtocol] = None
self.websocket: Optional[ws_client.ClientConnection] = None
self.connected: asyncio.Event = asyncio.Event()
self.websocket_uri: str = websocket_uri
self.retries: int = 0
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Winwing/pmdg_777_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def my_dispatch_proc(self, pData, cbData, pContext):

class MobiFlightClient:
def __init__(self, websocket_uri: str, max_retries: int = 3) -> None:
self.websocket: Optional[ws_client.WebSocketClientProtocol] = None
self.websocket: Optional[ws_client.ClientConnection] = None
self.connected: asyncio.Event = asyncio.Event()
self.websocket_uri: str = websocket_uri
self.retries: int = 0
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Winwing/tfdi_md11_winwing_cdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def my_dispatch_proc(self, pData, cbData, pContext):

class MobiFlightClient:
def __init__(self, websocket_uri: str, max_retries: int = 3) -> None:
self.websocket: Optional[ws_client.WebSocketClientProtocol] = None
self.websocket: Optional[ws_client.ClientConnection] = None
self.connected: asyncio.Event = asyncio.Event()
self.websocket_uri: str = websocket_uri
self.retries: int = 0
Expand Down
Loading