Skip to content

Commit 007f22d

Browse files
committed
Exit cleanly when no WiFi devices are available
1 parent 5803eed commit 007f22d

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828
context: .
2929
dockerfile: Dockerfile
3030
network_mode: "host"
31-
restart: always
31+
restart: on-failure
3232
volumes:
3333
- "py_wifi_connect_db:/app/db" # Optional if not setting the hotspot ssid and password via the API
3434
labels:

src/common/errors.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class WifiNetworkManagerError(Exception):
4646
pass
4747

4848

49-
class WifiNoSuitableDevice(Exception):
50-
pass
51-
52-
5349
# Custom error messages for Flask-RESTful to return
5450
errors = {
5551
"WifiConnectionFailed": {
@@ -72,8 +68,4 @@ class WifiNoSuitableDevice(Exception):
7268
"message": "Failed communicating with Network Manager.",
7369
"status": 500,
7470
},
75-
"WifiNoSuitableDevice": {
76-
"message": "No suitable Wi-Fi device available.",
77-
"status": 404,
78-
},
7971
}

src/common/wifi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import os
44
import socket
55
import subprocess
6+
import sys
67
import time
78
from common.errors import logger
89
from common.errors import WifiConnectionFailed
910
from common.errors import WifiDeviceNotFound
1011
from common.errors import WifiHotspotStartFailed
1112
from common.errors import WifiNetworkManagerError
12-
from common.errors import WifiNoSuitableDevice
1313
from common.nm_dicts import get_nm_dict
1414
from common.system import led
1515
from time import sleep
@@ -251,8 +251,8 @@ def get_device():
251251
if Pnm.NM_DEVICE_TYPE_WIFI in devices:
252252
return devices[Pnm.NM_DEVICE_TYPE_WIFI]
253253
else:
254-
logger.error("No suitable or available device found.")
255-
raise WifiNoSuitableDevice
254+
logger.error("No suitable or available device found. Exiting.")
255+
sys.exit(0)
256256

257257

258258
def list_access_points():

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy