refactor(memobird): switch to uv with inline script dependencies

This commit is contained in:
Moritz Graf 2026-05-19 22:00:13 +02:00
parent 64137350b4
commit 2a6709d5bc
3 changed files with 15 additions and 29 deletions

View File

@ -9,36 +9,32 @@ Direct printing to the Memobird thermal printer on the local network.
## 📦 Installation
This skill requires Python 3 and several libraries. Install them using:
This skill uses [uv](https://docs.astral.sh/uv/) for dependency management. No manual installation of Python packages is required as dependencies are declared inline within the script.
```bash
pip install -r requirements.txt
```
*Note: Depends on `requests` and `Pillow`.*
Ensure you have `uv` installed on your system.
## 🚀 Usage
Use the `scripts/memobird_print.py` tool. By default, it targets the static IP `192.168.10.165`.
Use `uv run` to execute the script. `uv` will automatically create a temporary environment and install the required dependencies (`requests`, `Pillow`).
### 1. Print simple text
```bash
./scripts/memobird_print.py --text "Hello from Gemini!"
uv run skills/memobird/scripts/memobird_print.py --text "Hello from Gemini!"
```
### 2. Print styled text
```bash
./scripts/memobird_print.py --text "IMPORTANT NOTE" --big --bold
uv run skills/memobird/scripts/memobird_print.py --text "IMPORTANT NOTE" --big --bold
```
### 3. Print an image
```bash
./scripts/memobird_print.py --image "path/to/image.png"
uv run skills/memobird/scripts/memobird_print.py --image "path/to/image.png"
```
### 4. Print a separator line
```bash
./scripts/memobird_print.py --line THICK
uv run skills/memobird/scripts/memobird_print.py --line THICK
```
## 🛠️ Options

View File

@ -1,2 +0,0 @@
requests
Pillow

View File

@ -1,4 +1,10 @@
#!/usr/bin/env python3
# /// script
# dependencies = [
# "requests",
# "pillow",
# ]
# ///
import sys
import os
import json
@ -6,22 +12,8 @@ import base64
from io import BytesIO
from random import randint
import argparse
# Dependency Check
MISSING_DEPS = []
try:
import requests
except ImportError:
MISSING_DEPS.append("requests")
try:
from PIL import Image as PILImg, ImageOps
except ImportError:
MISSING_DEPS.append("Pillow (PIL)")
if MISSING_DEPS:
print(f"Error: Missing dependencies: {', '.join(MISSING_DEPS)}")
print("Please install them using: pip install " + " ".join(["requests", "Pillow"]))
sys.exit(1)
import requests
from PIL import Image as PILImg, ImageOps
# Default IP for Moritz's Memobird
DEFAULT_HOST = "192.168.10.165"