Skip to content

Commit

Permalink
Some fixes (#57)
Browse files Browse the repository at this point in the history
* Fix add user functionality

* Set wifi credentials in settings

* Fix pylint
  • Loading branch information
leechwort committed Feb 5, 2024
1 parent 3788b81 commit 5896862
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:latest
WORKDIR /app
ENV PRISMO_CONFIG=/app/external/config_docker.json

Expand Down
10 changes: 9 additions & 1 deletion app/utils/fimware_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import re
import subprocess
import uuid
import os
from pathlib import Path

from flask import current_app as app
Expand Down Expand Up @@ -35,8 +36,15 @@ def update_firmware_full(socket, device_id):
data = {"text": "", "progress": 0, "status": "is_running"}
try:
script_path = Path(app.config["PRISMO"]["READER_FIRMWARE_FLASHING_SCRIPT_PATH"])
# Check and set wifi credentials as environment variables. Since flasher script requires
# them as ENV variables,and looks like Raspberry Pi OS do not allows to get wifi password
# to console, this trick is used here.
run_environment = os.environ.copy()
run_environment["HOST_WIFI_SSID"] = app.config["PRISMO"]["WIFI_SSID"]
run_environment["HOST_WIFI_PASSWORD"] = app.config["PRISMO"]["WIFI_PASSWORD"]
script_cwd = script_path.parent
process = subprocess.Popen([script_path, device_id], cwd=script_cwd, stdout=subprocess.PIPE)
process = subprocess.Popen([script_path, device_id], cwd=script_cwd,
stdout=subprocess.PIPE, env=run_environment)
except FileNotFoundError:
data["text"] = "Cannot find firmware update script"
data["status"] = "Device flashing failed"
Expand Down
24 changes: 0 additions & 24 deletions config_default.json

This file was deleted.

2 changes: 2 additions & 0 deletions config_docker_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"MAX_COOKIE_SIZE": 4093,
"DATABASE_URI": "file:./external/database.db",
"PRISMO": {
"WIFI_SSID": "yourSSID",
"WIFI_PASSWORD": "yourWifiPassword",
"ACTIVE_PLUGINS": [
"slack_notifier"
],
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ services:
volumes:
- "./data/:/app/external/"
- /run/udev:/run/udev:ro
privileged: true
devices:
# Here is some stuff to translate USB device to container.
- /dev/ttyUSB0:/dev/ttyUSB0:rw
Expand Down

0 comments on commit 5896862

Please sign in to comment.