chore(root): migrate touv and simplify dependencies
New Features - Added uv as the primary package manager and introduced new system packages awww, apple-fonts, swappy, and wl-clipboard. - Removed many redundant Python packages from the install script. Enhancements - Replaced Pillow-based QR code detection with GdkPixbuf, eliminating the python-pillow dependency. - Fixed a typo in the import (`ConfigServic` → `ConfigService`) and corrected service imports. - Updated the application launch to use `uwsm app -- uv run main.py` for uv-managed execution. Bug Fixes - Resolved import typo that prevented proper ConfigService initialization. - Adjusted QR-code decoding logic to correctly handle image pixel channels, improving robustness.
This commit is contained in:
3 files changed
+24
-33
No files matched your search
@@ -7,4 +7,4 @@ from .network import NetworkClient, Wifi, Ethernet, AccessPoint # noqa: F401
|
||||
from .mpris import MprisPlayer, MprisPlayerManager # noqa: F401
|
||||
from .todo import TodoService # noqa: F401
|
||||
from .modus import ModusService # noqa: F401
|
||||
from .config import on_config_change, start_config_service, ConfigServic # noqa: F401
|
||||
from .config import on_config_change, start_config_service, ConfigService # noqa: F401
|
||||
+20
-11
@@ -7,7 +7,7 @@ from pathlib import Path
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
import pyotp
|
||||
from PIL import Image
|
||||
from fabric.utils import GdkPixbuf
|
||||
from pyzbar.pyzbar import decode
|
||||
|
||||
import config.data as data
|
||||
@@ -70,15 +70,14 @@ def read_and_save_to_json():
|
||||
|
||||
# Open the captured image
|
||||
try:
|
||||
img = Image.open(screenshot)
|
||||
except Exception as e:
|
||||
print("Error opening the image:", e)
|
||||
return False
|
||||
|
||||
# Decode QR Code(s) from the image
|
||||
decoded_objects = decode(img)
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(screenshot)
|
||||
pixels = pixbuf.get_pixels()
|
||||
channels = pixbuf.get_n_channels()
|
||||
gray_pixels = pixels[::channels]
|
||||
decoded_objects = decode((gray_pixels, pixbuf.get_width(), pixbuf.get_height()))
|
||||
finally:
|
||||
del pixbuf
|
||||
if not decoded_objects:
|
||||
print("No QR Code detected in the selected area.")
|
||||
return False
|
||||
|
||||
results = []
|
||||
@@ -279,8 +278,18 @@ def scan_qr_and_add_account(account_name: str, secrets_file_path: str) -> dict:
|
||||
|
||||
# Decode QR code
|
||||
try:
|
||||
img = Image.open(screenshot_path)
|
||||
decoded_objects = decode(img)
|
||||
try:
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(screenshot_path)
|
||||
pixels = pixbuf.get_pixels()
|
||||
channels = pixbuf.get_n_channels()
|
||||
gray_pixels = pixels[::channels]
|
||||
decoded_objects = decode(
|
||||
(gray_pixels, pixbuf.get_width(), pixbuf.get_height())
|
||||
)
|
||||
finally:
|
||||
# Delete pixbuf to free native memory immediately
|
||||
if "pixbuf" in locals():
|
||||
del pixbuf
|
||||
|
||||
if not decoded_objects:
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user