Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
previ committed Feb 17, 2023
2 parents 36b1576 + 6aa85fa commit be3239f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 26 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -64,4 +64,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
Expand All @@ -50,7 +50,7 @@ jobs:
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libdbus-glib-1-dev libgirepository1.0-dev
python -m pip install --upgrade pip
pip install flake8 pytest
pip install flake8 pytest wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ RUN apk add --no-cache \
build-base \
dbus-dev \
dbus-libs \
git \
glib-dev

# Copy Python requirements file
COPY src/requirements.txt /tmp/

# Install packages into a directory
RUN pip install wheel --no-cache-dir
RUN pip install --user -r /tmp/requirements.txt --no-cache-dir


Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ services:
context: .
dockerfile: Dockerfile
network_mode: "host"
restart: always
restart: on-failure
volumes:
- "py_wifi_connect_db:/app/db" # Optional if not setting the hotspot ssid and password via the API
labels:
Expand Down
8 changes: 0 additions & 8 deletions src/common/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ class WifiNetworkManagerError(Exception):
pass


class WifiNoSuitableDevice(Exception):
pass


# Custom error messages for Flask-RESTful to return
errors = {
"WifiConnectionFailed": {
Expand All @@ -72,8 +68,4 @@ class WifiNoSuitableDevice(Exception):
"message": "Failed communicating with Network Manager.",
"status": 500,
},
"WifiNoSuitableDevice": {
"message": "No suitable Wi-Fi device available.",
"status": 404,
},
}
6 changes: 3 additions & 3 deletions src/common/wifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import os
import socket
import subprocess
import sys
import time
from common.errors import logger
from common.errors import WifiConnectionFailed
from common.errors import WifiDeviceNotFound
from common.errors import WifiHotspotStartFailed
from common.errors import WifiNetworkManagerError
from common.errors import WifiNoSuitableDevice
from common.nm_dicts import get_nm_dict
from common.system import led
from time import sleep
Expand Down Expand Up @@ -251,8 +251,8 @@ def get_device():
if Pnm.NM_DEVICE_TYPE_WIFI in devices:
return devices[Pnm.NM_DEVICE_TYPE_WIFI]
else:
logger.error("No suitable or available device found.")
raise WifiNoSuitableDevice
logger.error("No suitable or available WiFi device found. Exiting.")
sys.exit(0)


def list_access_points():
Expand Down
4 changes: 2 additions & 2 deletions src/requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
python-dotenv
git+https://github.com/balena-io-experimental/python-networkmanager
Flask-Cors
Flask-RESTful
python-networkmanager==2.1
python-dotenv
waitress
6 changes: 3 additions & 3 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile
#
Expand All @@ -26,7 +26,7 @@ markupsafe==2.1.0
# via jinja2
python-dotenv==0.19.2
# via -r requirements.in
python-networkmanager==2.1
python-networkmanager @ git+https://github.com/balena-io-experimental/python-networkmanager
# via -r requirements.in
pytz==2021.3
# via flask-restful
Expand Down

0 comments on commit be3239f

Please sign in to comment.