1 Commits
Author SHA1 Message Date
ahtlon 6b98e65a41 Fix #27. Also clear up error messages a bit 2026-08-08 00:26:02 +02:00
5 changed files with 23 additions and 72 deletions
-33
View File
@@ -1,33 +0,0 @@
name: Pull-Request Vibe Check
on:
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
ci-test:
runs-on: node-current
steps:
- name: Setup PRBot
uses: imgurbot12/prbot@v2
with:
username: ${{ secrets.prbot_username }}
api_token: ${{ secrets.prbot_token }}
- uses: actions/checkout@v6
- name: Set up UV
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
- run: |
apt update
apt install libpcsclite-dev python3-dev -y
- name: Install deps
run: uv sync --locked --all-extras --dev
- name: Run ruff check
run: uv run ruff check --output-format=github | sed 's|/workspace/malobeo/gatekeeper/||' | prbot
continue-on-error: true
- name: Post PR Feedback
if: always()
run: prbot commit
-21
View File
@@ -1,21 +0,0 @@
name: Test python action
on: [push]
jobs:
test:
runs-on: node-current
steps:
- uses: actions/checkout@v6
- name: Set up UV
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
- run: |
apt update
apt install libpcsclite-dev python3-dev -y
- name: Install deps
run: uv sync --locked --all-extras --dev
- name: Run tests
run: uv run pytest test
+1 -1
View File
@@ -133,4 +133,4 @@ def checkAccess(key: str, db: Session):
logger.info("No more auths found")
return False
except exc.NoResultFound:
raise Exception("No Access with that key found, this might be a db error")
raise Exception("No AccessAuth with that key found!")
+14 -17
View File
@@ -77,7 +77,7 @@ def readFileOnCard(desfire: DESFire):
assert len(applications) == 1
assert applications[0] == get_list(MIFARE_APP_ID)
except AssertionError:
logger.error("No application found!")
logger.error("No application found! The card must be registered first!")
time.sleep(4)
return
# Then use the key derivation with that uid, the appid, the sysid
@@ -125,23 +125,13 @@ def DeleteCard():
aes_null_key = DESFireKey(aes_keysettings, "00" * 16)
desfire.select_application(0x0)
try:
try:
logger.debug("Auth1")
desfire.authenticate(0x0, aes_master_key)
except:
logger.debug("Auth2")
desfire.authenticate(0x0, aes_null_key)
except:
logger.debug("Auth3")
desfire.authenticate(0x0, desKey)
desfire.authenticate(0x0, desKey)
applications = desfire.get_application_ids()
logger.debug(f"Applications: {applications}")
if len(applications) == 0:
raise HTTPException(
status_code=status.HTTP_410_GONE, detail="No applications on card"
status_code=status.HTTP_410_GONE, detail="Card is empty."
)
desfire.select_application(MIFARE_APP_ID)
@@ -185,6 +175,13 @@ def WriteNewCard():
# get uid
uid = desfire.get_real_uid()
applications = desfire.get_application_ids()
logger.debug(f"Applications: {applications}")
if len(applications) >= 1:
raise HTTPException(
status_code=status.HTTP_409_CONFLICT, detail="This Card already has a key!"
)
# Set default key
logger.debug("Setting default key...")
desfire.change_default_key(aes_null_key, 0x0)
@@ -270,12 +267,12 @@ def WriteNewCard():
return key, to_hex_string(data=uid, separator=":")
except Exception as e:
logger.error(f"Error in write function: {e}", exc_info=True)
logger.error(f"Error in write function: {e}", exc_info=False)
scannerThread.start()
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail=f"Error: {e}"
)
class BackgroundScanner:
def __init__(self, db):
self.db = db
@@ -310,7 +307,7 @@ class BackgroundScanner:
logger.debug("READY after timout")
except Exception as e:
logger.error(f"Error in scan function: {e}", exc_info=True)
logger.error(f"Error in function _scan_loop: {e}", exc_info=False)
time.sleep(6)
def _read_card(self):
@@ -326,7 +323,7 @@ class BackgroundScanner:
rdata = readFileOnCard(desfire=desfire)
return rdata
except Exception as e:
logger.error(f"something went wrong: {e}")
logger.error(f"Error in function _read_card: {e}", exc_info=False)
time.sleep(5)
def _check_db(self, key):
Generated
+8
View File
@@ -659,6 +659,7 @@ source = { virtual = "." }
dependencies = [
{ name = "alembic" },
{ name = "fastapi", extra = ["standard"] },
{ name = "lgpio", marker = "platform_machine == 'aarch64' and sys_platform == 'linux'" },
{ name = "paho-mqtt" },
{ name = "poetry" },
{ name = "pwdlib", extra = ["argon2"] },
@@ -683,6 +684,7 @@ dev = [
requires-dist = [
{ name = "alembic", specifier = ">=1.18.5" },
{ name = "fastapi", extras = ["standard"], specifier = ">=0.135.3" },
{ name = "lgpio", marker = "platform_machine == 'aarch64' and sys_platform == 'linux'", specifier = ">=0.2.2.0" },
{ name = "paho-mqtt", specifier = ">=2.1.0" },
{ name = "poetry", specifier = ">=2.3.4" },
{ name = "pwdlib", extras = ["argon2"], specifier = ">=0.3.0" },
@@ -931,6 +933,12 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/81/db/e655086b7f3a705df045bf0933bdd9c2f79bb3c97bfef1384598bb79a217/keyring-25.7.0-py3-none-any.whl", hash = "sha256:be4a0b195f149690c166e850609a477c532ddbfbaed96a404d4e43f8d5e2689f", size = 39160, upload-time = "2025-11-16T16:26:08.402Z" },
]
[[package]]
name = "lgpio"
version = "0.2.2.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/56/33/26ec2e8049eaa2f077bf23a12dc61ca559fbfa7bea0516bf263d657ae275/lgpio-0.2.2.0.tar.gz", hash = "sha256:11372e653b200f76a0b3ef8a23a0735c85ec678a9f8550b9893151ed0f863fff", size = 90087, upload-time = "2024-03-29T21:59:55.901Z" }
[[package]]
name = "lsprotocol"
version = "2025.0.0"