A standalone Python library for controlling 3D printers (Bambu Lab, Klipper, OctoPrint, and more)
Project description
SeFleet
SeFleet is a standalone Python library for controlling 3D printers. It was extracted and optimized from the spdbridge project's printer module, refactored into a clean, pip-installable package.
Supported Printers
| Printer Type | Class | Protocol |
|---|---|---|
| Bambu Lab (A1, X1, P1 series) | BambuLabPrinter |
MQTT + FTP |
| Klipper-based (Ender 3, Voron, etc.) | KlipperPrinter |
HTTP REST API |
| OctoPrint-based | OctoprintPrinter |
HTTP REST API |
| Ender 5 Max (Chinese variant) | Ender5MaxChinesePrinter |
WebSocket |
| Anycubic Kobra OS Cloud | KobraOsCloudPrinter |
Cloud HTTP API |
| Elegoo Saturn 4 Ultra | Saturn4UltraPrinter |
WebSocket (SDCP) |
Installation
pip install sefleet
Quick Start
import asyncio
from sefleet import create_printer, PrinterType
async def main():
# Create a Klipper printer
printer = create_printer(
printer_type=PrinterType.KLIPPER,
address_control="http://192.168.1.100:7125"
)
# Home the printer
await printer.runHome()
# Check temperature
temp = await printer.getTemperature()
print(f"Bed: {temp['bed']}°C, Nozzle: {temp['nozzle']}°C")
# Upload and print a file
with open("model.gcode", "rb") as f:
result = await printer.uploadFile("model.gcode", f)
if result:
await printer.printModel("model.gcode")
# Monitor print status
while True:
stat = await printer.getPrintStat()
if stat.get("currentStatus") == "IDLE":
break
await asyncio.sleep(10)
# Cancel if needed
await printer.runCancel()
asyncio.run(main())
API Reference
Factory Function
sefleet.create_printer(printer_type: PrinterType, **kwargs) -> BasePrinter
Common Methods (all printers)
| Method | Description |
|---|---|
runHome() |
Home all axes |
getTemperature() |
Return {'bed': float, 'nozzle': float} |
getPrintStat() |
Return {'currentStatus': 'IDLE'|'BUSY'|'UNKNOWN'} |
isReadyState() |
Return True if printer is idle |
printModel(filename, **kwargs) |
Start printing a file |
runCancel() |
Cancel current print job |
runPause() |
Pause printing |
runResume() |
Resume printing |
uploadFile(filename, file_stream) |
Upload a file to the printer |
removeFile(filename) |
Delete a file from the printer |
captureImage(addressCamera, file_path) |
Capture a snapshot from camera |
getInfoMachine() |
Get detailed printer information |
runRestart() |
Restart the printer firmware |
runScript(script) |
Execute raw G-code or command |
doJob(filename, **kwargs) |
Full job execution loop (upload → print → wait) |
Project Structure
sefleet/
├── __init__.py # Public API exports
├── base.py # Abstract base class (BasePrinter)
├── bambulab.py # Bambu Lab implementation
├── klipper.py # Klipper implementation
├── octoprint.py # OctoPrint implementation
├── ender5maxchinese.py # Ender 5 Max Chinese implementation
├── kobraoscloud.py # Kobra OS Cloud implementation
├── saturn4ultra.py # Saturn 4 Ultra implementation
├── factory.py # Printer factory function
pyproject.toml # Package metadata and build config
Implementation Plan
Phase 1: Extract & Refactor
- Extract printer classes from
spdbridge/src/printer/into standalone modules - Remove all
spdbridge-specific dependencies (e.g.,src.library.*,src.controller.*,src.model.*) - Remove failure detection logic (
doJobWithFailureDetection,_handle_failure_detection) — keep only core printer control - Remove WebSocket/Socket.IO broadcasting dependencies
- Replace
src.library.handlerreferences with standalone implementations where needed
Phase 2: Package Structure
- Create
pyproject.tomlwith proper metadata and dependencies - Create
sefleet/package directory - Implement factory pattern for easy printer creation
Phase 3: Dependencies
aiohttp— HTTP and WebSocket clientbambulabs-api-compatible— Bambu Lab printer protocolrequests— Synchronous HTTP (for Ender 5 Max upload)certifi— SSL certificates (for Kobra OS Cloud)ffmpeg(system dependency) — Camera capture (Saturn 4 Ultra)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sefleet-0.1.0.tar.gz
(20.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sefleet-0.1.0-py3-none-any.whl
(24.4 kB
view details)
File details
Details for the file sefleet-0.1.0.tar.gz.
File metadata
- Download URL: sefleet-0.1.0.tar.gz
- Upload date:
- Size: 20.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9a5dd7909f08dceacc2f156c21aac7d85f5ee0b68d9517a9ece978629815ba3
|
|
| MD5 |
9bb96f169bd2a5daa2ce8a253e34441d
|
|
| BLAKE2b-256 |
750c9711aafd44c9ab71effae194da3859e04cd921951b88587da4383fe39f13
|
File details
Details for the file sefleet-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sefleet-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f92f990bcab727189297a423fc51af6ffed94f7c16c15886946a8847a7d7b3b
|
|
| MD5 |
115b0424385f559fc6147ec82dcebe3a
|
|
| BLAKE2b-256 |
23005b3cc826f09dcc9ad7fcd081a123233062ce1795a1071b985ef37c29b3d3
|