Name | PrusaLinkPy JSON |
Version |
2.2.0
JSON |
| download |
home_page | None |
Summary | A library to interface with the PrusaLink API |
upload_time | 2024-05-13 14:24:22 |
maintainer | None |
docs_url | None |
author | Guillaume RICO |
requires_python | >=3.7 |
license | Copyright (c) 2023 Guillaume RICO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
prusalink
api
mini
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
PrusaLinkPy is a library to use the Prusa Link API.
The library makes it easy to use the prusa API in python. The library is based on Request.
Example of use :
# Library import
import PrusaLinkPy
# Printer instantiation
# IP : 192.168.0.123
# API KEY : 8ojHKHGNuAHA2bM
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
# Get bed temperature
getPrint = prusaMini.get_printer()
# Display bed temperature
print(getPrint.json()["telemetry"]["temp-bed"])
# Delete a files on USB drive :
prusaMini.delete("/5H30M_~1.GCO")
# Transferring a file to the printer
if not prusaMini.exists_gcode('FOLDER/test.gcode') :
prusaMini.put_gcode('C:/AM/test.gcode', 'FOLDER/test.gcode')
# List files on USB Drive :
prusaMini.get_files().json()["children"]
# Print this file
prusaMini.post_print_gcode('/usb/test.gcode')
The library changed its name in May 2024. Before it was called prusaLink.
Prusa staff asked me to leave them the name.
# Change Log
## 2.2 :
Version made by [enrgarci](https://github.com/enrgarci)
- Update README.md
- Modified delete_job() to fix request from get to delete
- added :
* pause_print
* resume_print
* stop_print
## 2.1.1 :
- Update README.md
- added :
* get_transfer
* get_settings
## 2.1.0 :
- Update README.md
- added :
* delete
* get_status
* get_storage
* delete_job
## 2.0.1 :
- Bug correction on put_gcode
## 2.0.0 :
- Support firmware 5.1.0
- Added :
* get_files
* put_gcode
* exists_gcode
## 1.0.0 :
- First Release
# Installing PrusaLinkPy and Supported Versions
PrusaLinkPy is available on pip :
python -m pip install PrusaLinkPy
PrusaLinkPy officially supports Python 3.9+ with Prusa MINI printer firmware 5.1.0.
# API Reference
## Low Level Functions
[get_version()](#prusalinkpyget_version)
[get_printer()](#prusalinkpyget_printer)
[get_job()](#prusalinkpyget_job)
[delete_job()](#prusalinkpydelete_job)
[get_status()](#prusalinkpyget_status)
[get_storage()](#prusalinkpyget_storage)
[get_files(remoteDir)](#prusalinkpyget_files-remotedir--)
[delete(remotePath)](#prusalinkpydeleteremotepath)
[post_gcode(remotePath)](#prusalinkpyput_post_gcode)
[put_gcode(filePathLocal, remoteDir, printAfterUpload = False, overwrite = False)](#prusalinkpyput_gcoderemotepath)
[exists_gcode(remotePath)](#prusalinkpyexists_gcoderemotepath)
[pause_print()](#prusalinkpypause_print)
[resume_print()](#prusalinkpyresume_print)
[stop_print()](#prusalinkpystop_print)
## High Level Functions
[get_recursive_files(remoteDir)](#prusalinkpyget_recursive_files-remotedir--)
# User Guide
## PrusaLinkPy.get_version()
Read version :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM", port=8017)
obj = prusaMini.get_version()
obj.json()
Return something like :
{
'api': '2.0.0',
'server': '2.1.2',
'nozzle_diameter': 0.4,
'text': 'PrusaLink',
'hostname': '',
'capabilities':
{
'upload-by-put': True
}
}
## PrusaLinkPy.get_printer()
Get printer :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_printer()
obj.json()
Waiting for Changing Filament :
'link_state': 'ATTENTION'
'error': True
Return something like :
{
'telemetry':
{
'temp-bed': 16.3,
'temp-nozzle': 16.7,
'print-speed': 100,
'z-height': 82.0,
'material': 'PLA'
},
'temperature':
{
'tool0':
{
'actual': 16.7,
'target': 0.0,
'display': 0.0,
'offset': 0
},
'bed':
{
'actual':16.3,
'target': 0.0,
'offset': 0
}
},
'state':
{
'text': 'Operational',
'flags':
{
'operational': True,
'paused': False,
'printing': False,
'cancelling': False,
'pausing': False,
'error': False,
'sdReady': False,
'closedOnError': False,
'ready': True,
'busy': False
}
}
}
## PrusaLinkPy.get_job()
Get job :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_job()
obj.json()
Return something like :
{
"state":"Operational",
"job": None,
"progress": None
}
## PrusaLinkPy.delete_job(job)
Delete a job. Job number is available with get_job() or get_status()
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.delete_job("43")
## PrusaLinkPy.get_status()
Get job :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_status()
obj.json()
Value of printer->state :
IDLE (Main Screen)
PRINTING
FINISHED (Print finish, screen not on main screen)
PAUSED (Pause by user, Print fan error)
STOPPED (Print finish, stopped by user)
ATTENTION (Filament Change)
Return something like :
{
"job":
{
"id":43,
"progress":0.00,
"time_remaining":120,
"time_printing":143
},
"storage":
{
"path":"/usb/",
"name":"usb",
"read_only":false
},
"printer":
{
"state":"PRINTING",
"temp_bed":57.3,
"target_bed":0.0,
"temp_nozzle":24.1,
"target_nozzle":0.0,
"axis_z":162.2,
"flow":100,
"speed":100,
"fan_hotend":0,
"fan_print":0
}
}
## PrusaLinkPy.get_storage()
Get job :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_storage()
obj.json()
Return something like :
{
'storage_list':
[
{
'path': '/usb/',
'name': 'usb',
'type': 'USB',
'read_only': False,
'available': True
}
]
}
## PrusaLinkPy.get_transfer()
Not Tested
Get job :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_transfer()
obj.text
Return something like :
TODO
## PrusaLinkPy.get_settings()
Completely useless
See here :
https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/4bea923810302d654b932291ba324eaedff072fc/lib/WUI/link_content/prusa_link_api.cpp#L181C16-L181C16
Comment from Prusa Developper :
// Some stubs for now, to make more clients (including the web page) happier.
Get job :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_transfer()
obj.text
Return something like :
{"printer": {}}
## PrusaLinkPy.get_files( remoteDir = '/')
Get Files on USB Drive :
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.get_files()
filesRet = obj.json()
Return something like :
{
'type': 'FOLDER',
'ro': False,
'name': 'usb',
'children':
[
{
'name': 'MTN',
'ro': False,
'type': 'FOLDER',
'm_timestamp': 1702628945,
'display_name': 'MTN'
},
{
'name': 'S2_V2IS',
'ro': False,
'type': 'FOLDER',
'm_timestamp': 1702565182,
'display_name': 'S2_V2IS'
}
]
}
Workalso with subfolder
obj = prusaMini.get_files(remoteDir = '/SUBFOLDER')
## PrusaLinkPy.get_recursive_files( remoteDir = '/')
Get all files (only gcode and bgcode) in a folder and subfolder.
Warning : return nested dict.
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
dictt = prusaMini.get_recursive_files()
{
'MTN':
{
'CHGT_BUSE.gcode': '/MTN/CHGT_B~1.GCO',
'DEBOUCHAGE.gcode': '/MTN/DEBOUC~1.GCO',
'PRECHAUFFE.gcode': '/MTN/PRECHA~1.GCO'
},
'S2_V2IS':
{
'2h33m.bgcode': '/S2_V2IS/2H33M~1.BGC',
'5h5m.bgcode': '/S2_V2IS/5H5M~1.BGC'
}
}
## PrusaLinkPy.delete(remotePath)
Delete a file or a folder on USB drive
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.delete('/DEBOUC~1.GCO')
## PrusaLinkPy.post_gcode(remotePath)
Print a file already poresent on USB key
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
obj = prusaMini.post_gcode('/DEBOUC~1.GCO')
## PrusaLinkPy.put_gcode(remotePath, printAfterUpload = False, overwrite = False)
Send a file on USB Drive.
Can create a folder !
if ret.status_code = 409 -> Conflict : File already exists
if ret.status_code = 415 -> {"title": "415: Unsupported Media Type","message":"Not a GCODE"}
printAfterUpload : Set at True to print after upload.
overwrite : Allow file Overwrite
FW 5.1.0 :
* Warning: printing starts even if the bed is not empty
* Can only send bgcode and gcode
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
status = prusaMini.put('C:/MTN/DEBOUCHAGE.gcode' , 'MTN/DEBOUCHAGE.gcode')
# Overwrite
status = prusaMini.put('C:/MTN/DEBOUCHAGE.gcode' , 'MTN/DEBOUCHAGE.gcode', False, True)
# Overwrite and Print
status = prusaMini.put('C:/MTN/DEBOUCHAGE.gcode' , 'MTN/DEBOUCHAGE.gcode', True, True)
## PrusaLinkPy.exists_gcode(remotePath)
Check if a file exists on USB drive.
Return True or False
import PrusaLinkPy
prusaMini = PrusaLinkPy.PrusaLinkPy("192.168.0.123", "8ojHKHGNuAHA2bM")
status = prusaMini.exists_gcode('/DEBOUC~1.GCO')
## PrusaLinkPy.pause_print()
Pause actual print.
Added in 2.2.0 .
## PrusaLinkPy.resume_print()
Resume paused print.
Added in 2.2.0 .
## PrusaLinkPy.stop_print()
Stop actual print.
Added in 2.2.0 .
# API
API not implemented in my lib :
* retrieve thumbnail :
r = requests.get('http://192.168.0.123:8017/thumb/l/usb/TAVERN~1.GCO', headers=headers)
/api/settings
POST /api/job
**[Link to Buddy code](https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/lib/WUI/link_content/prusa_link_api.cpp#L276)**
GET/POST /api/download
**[Link to Buddy code](https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/lib/WUI/link_content/prusa_link_api.cpp#L289)**
# Bugs present in Prusa MINI printer firmware 4.4.1:
* There is no possibility to have the list of folders present in a directory
* Solved in firmware 5
* You cannot upload a gcode in a subfolder of the USB key
* Solved in firmware 5
* When the printer detects the end of the filament and it displays "Change Filament" the telemetry information is no longer good. Here is the information returned by the printer in this case:
'telemetry': {'temp-bed': 0.0, 'temp-nozzle': 0.0, 'print-speed': 100, 'z-height': 0.0, 'material': '---'}
* Still in the case of a filament change, the status information is incorrect:
'state': {'text': 'Operational', 'flags': {'operational': True, 'paused': False, 'printing': False, 'cancelling': False, 'pausing': False, 'sdReady': False, 'error': False, 'closedOnError': False, 'ready': True, 'busy': False}
# Inspiration
An other lib :
https://github.com/home-assistant-libs/PrusaLinkPy/blob/main/PrusaLinkPy/
Les commandes dans la mini :
https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/lib/WUI/link_content/basic_gets.cpp
# Construire la lib
py -m build
To upload to testpi repo :
py -m twine upload --repository testpi dist/*
To upload to pypi repo :
py -m twine upload dist/*
https://medium.com/analytics-vidhya/how-to-create-a-python-library-7d5aea80cc3f
Raw data
{
"_id": null,
"home_page": null,
"name": "PrusaLinkPy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "Prusalink, API, Mini",
"author": "Guillaume RICO",
"author_email": "Guillaume RICO <guillaume.rico@alpesmesures.fr>",
"download_url": "https://files.pythonhosted.org/packages/5e/20/147fb335a6887e94cd51cc87feb9b4a59eb1031149348e06631be72cce92/prusalinkpy-2.2.0.tar.gz",
"platform": null,
"description": "\r\nPrusaLinkPy is a library to use the Prusa Link API.\r\n\r\nThe library makes it easy to use the prusa API in python. The library is based on Request.\r\n\r\nExample of use :\r\n\r\n # Library import\r\n import PrusaLinkPy\r\n \r\n # Printer instantiation\r\n # IP : 192.168.0.123\r\n # API KEY : 8ojHKHGNuAHA2bM\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n \r\n # Get bed temperature\r\n getPrint = prusaMini.get_printer()\r\n \r\n # Display bed temperature\r\n print(getPrint.json()[\"telemetry\"][\"temp-bed\"])\r\n \r\n # Delete a files on USB drive :\r\n prusaMini.delete(\"/5H30M_~1.GCO\")\r\n \r\n # Transferring a file to the printer\r\n if not prusaMini.exists_gcode('FOLDER/test.gcode') :\r\n prusaMini.put_gcode('C:/AM/test.gcode', 'FOLDER/test.gcode')\r\n \r\n # List files on USB Drive :\r\n prusaMini.get_files().json()[\"children\"]\r\n \r\n # Print this file \r\n prusaMini.post_print_gcode('/usb/test.gcode')\r\n \r\n\r\nThe library changed its name in May 2024. Before it was called prusaLink.\r\nPrusa staff asked me to leave them the name.\r\n\r\n# Change Log \r\n\r\n## 2.2 :\r\n\r\n Version made by [enrgarci](https://github.com/enrgarci)\r\n - Update README.md\r\n - Modified delete_job() to fix request from get to delete\r\n - added :\r\n\r\n * pause_print\r\n * resume_print\r\n * stop_print\r\n\r\n## 2.1.1 :\r\n\r\n - Update README.md\r\n - added :\r\n\r\n * get_transfer\r\n * get_settings\r\n \r\n## 2.1.0 :\r\n\r\n - Update README.md\r\n - added :\r\n\r\n * delete\r\n * get_status\r\n * get_storage\r\n * delete_job\r\n \r\n## 2.0.1 :\r\n\r\n - Bug correction on put_gcode\r\n \r\n## 2.0.0 :\r\n\r\n - Support firmware 5.1.0\r\n - Added : \r\n\r\n * get_files\r\n * put_gcode\r\n * exists_gcode\r\n \r\n## 1.0.0 :\r\n\r\n - First Release\r\n\r\n# Installing PrusaLinkPy and Supported Versions\r\n\r\nPrusaLinkPy is available on pip :\r\n\r\n python -m pip install PrusaLinkPy\r\n\r\nPrusaLinkPy officially supports Python 3.9+ with Prusa MINI printer firmware 5.1.0.\r\n\r\n\r\n# API Reference\r\n\r\n## Low Level Functions\r\n\r\n[get_version()](#prusalinkpyget_version)\r\n\r\n[get_printer()](#prusalinkpyget_printer)\r\n\r\n[get_job()](#prusalinkpyget_job)\r\n\r\n[delete_job()](#prusalinkpydelete_job)\r\n\r\n[get_status()](#prusalinkpyget_status)\r\n\r\n[get_storage()](#prusalinkpyget_storage)\r\n\r\n[get_files(remoteDir)](#prusalinkpyget_files-remotedir--)\r\n\r\n[delete(remotePath)](#prusalinkpydeleteremotepath)\r\n\r\n[post_gcode(remotePath)](#prusalinkpyput_post_gcode)\r\n\r\n[put_gcode(filePathLocal, remoteDir, printAfterUpload = False, overwrite = False)](#prusalinkpyput_gcoderemotepath)\r\n\r\n[exists_gcode(remotePath)](#prusalinkpyexists_gcoderemotepath)\r\n\r\n[pause_print()](#prusalinkpypause_print)\r\n\r\n[resume_print()](#prusalinkpyresume_print)\r\n\r\n[stop_print()](#prusalinkpystop_print)\r\n\r\n## High Level Functions \r\n\r\n[get_recursive_files(remoteDir)](#prusalinkpyget_recursive_files-remotedir--)\r\n\r\n\r\n# User Guide\r\n\r\n## PrusaLinkPy.get_version()\r\n\r\nRead version :\r\n\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\", port=8017)\r\n obj = prusaMini.get_version()\r\n obj.json()\r\n \r\nReturn something like :\r\n\r\n {\r\n 'api': '2.0.0', \r\n 'server': '2.1.2', \r\n 'nozzle_diameter': 0.4, \r\n 'text': 'PrusaLink', \r\n 'hostname': '', \r\n 'capabilities': \r\n {\r\n 'upload-by-put': True\r\n }\r\n }\r\n\r\n\r\n## PrusaLinkPy.get_printer()\r\n\r\nGet printer :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_printer()\r\n obj.json()\r\n \r\nWaiting for Changing Filament :\r\n\r\n 'link_state': 'ATTENTION' \r\n 'error': True\r\n \r\nReturn something like :\r\n\r\n {\r\n 'telemetry': \r\n {\r\n 'temp-bed': 16.3,\r\n 'temp-nozzle': 16.7,\r\n 'print-speed': 100,\r\n 'z-height': 82.0,\r\n 'material': 'PLA'\r\n }, \r\n 'temperature': \r\n {\r\n 'tool0': \r\n {\r\n 'actual': 16.7,\r\n 'target': 0.0,\r\n 'display': 0.0,\r\n 'offset': 0\r\n },\r\n 'bed': \r\n {\r\n 'actual':16.3,\r\n 'target': 0.0,\r\n 'offset': 0\r\n }\r\n },\r\n 'state': \r\n {\r\n 'text': 'Operational',\r\n 'flags': \r\n {\r\n 'operational': True,\r\n 'paused': False,\r\n 'printing': False,\r\n 'cancelling': False,\r\n 'pausing': False,\r\n 'error': False,\r\n 'sdReady': False,\r\n 'closedOnError': False,\r\n 'ready': True,\r\n 'busy': False\r\n }\r\n }\r\n }\r\n\r\n## PrusaLinkPy.get_job()\r\n\r\nGet job :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_job()\r\n obj.json()\r\n \r\nReturn something like :\r\n\r\n {\r\n \"state\":\"Operational\",\r\n \"job\": None,\r\n \"progress\": None\r\n }\r\n \r\n## PrusaLinkPy.delete_job(job)\r\n\r\nDelete a job. Job number is available with get_job() or get_status()\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.delete_job(\"43\")\r\n \r\n\r\n## PrusaLinkPy.get_status()\r\n\r\nGet job :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_status()\r\n obj.json()\r\n \r\nValue of printer->state :\r\n\r\n IDLE (Main Screen)\r\n PRINTING\r\n FINISHED (Print finish, screen not on main screen)\r\n PAUSED (Pause by user, Print fan error)\r\n STOPPED (Print finish, stopped by user)\r\n ATTENTION (Filament Change)\r\n \r\nReturn something like :\r\n\r\n {\r\n \"job\":\r\n {\r\n \"id\":43,\r\n \"progress\":0.00,\r\n \"time_remaining\":120,\r\n \"time_printing\":143\r\n },\r\n \"storage\":\r\n {\r\n \"path\":\"/usb/\",\r\n \"name\":\"usb\",\r\n \"read_only\":false\r\n },\r\n \"printer\":\r\n {\r\n \"state\":\"PRINTING\",\r\n \"temp_bed\":57.3,\r\n \"target_bed\":0.0,\r\n \"temp_nozzle\":24.1,\r\n \"target_nozzle\":0.0,\r\n \"axis_z\":162.2,\r\n \"flow\":100,\r\n \"speed\":100,\r\n \"fan_hotend\":0,\r\n \"fan_print\":0\r\n }\r\n }\r\n \r\n## PrusaLinkPy.get_storage()\r\n\r\nGet job :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_storage()\r\n obj.json()\r\n \r\nReturn something like :\r\n\r\n {\r\n 'storage_list': \r\n [\r\n {\r\n 'path': '/usb/', \r\n 'name': 'usb',\r\n 'type': 'USB', \r\n 'read_only': False, \r\n 'available': True\r\n }\r\n ]\r\n }\r\n \r\n## PrusaLinkPy.get_transfer()\r\n\r\nNot Tested\r\n\r\nGet job :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_transfer()\r\n obj.text\r\n \r\nReturn something like :\r\n\r\n TODO\r\n \r\n## PrusaLinkPy.get_settings()\r\n\r\nCompletely useless\r\n\r\nSee here :\r\n\r\nhttps://github.com/prusa3d/Prusa-Firmware-Buddy/blob/4bea923810302d654b932291ba324eaedff072fc/lib/WUI/link_content/prusa_link_api.cpp#L181C16-L181C16\r\n\r\nComment from Prusa Developper :\r\n\r\n // Some stubs for now, to make more clients (including the web page) happier.\r\n\r\nGet job :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_transfer()\r\n obj.text\r\n \r\nReturn something like :\r\n\r\n {\"printer\": {}}\r\n \r\n## PrusaLinkPy.get_files( remoteDir = '/')\r\n\r\nGet Files on USB Drive :\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.get_files()\r\n filesRet = obj.json()\r\n \r\nReturn something like :\r\n\r\n {\r\n 'type': 'FOLDER', \r\n 'ro': False, \r\n 'name': 'usb', \r\n 'children': \r\n [\r\n {\r\n 'name': 'MTN', \r\n 'ro': False, \r\n 'type': 'FOLDER', \r\n 'm_timestamp': 1702628945, \r\n 'display_name': 'MTN'\r\n },\r\n {\r\n 'name': 'S2_V2IS', \r\n 'ro': False, \r\n 'type': 'FOLDER', \r\n 'm_timestamp': 1702565182, \r\n 'display_name': 'S2_V2IS'\r\n }\r\n ]\r\n }\r\n \r\nWorkalso with subfolder\r\n\r\n obj = prusaMini.get_files(remoteDir = '/SUBFOLDER')\r\n\r\n## PrusaLinkPy.get_recursive_files( remoteDir = '/')\r\n\r\nGet all files (only gcode and bgcode) in a folder and subfolder.\r\n\r\nWarning : return nested dict.\r\n\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n dictt = prusaMini.get_recursive_files()\r\n \r\n {\r\n 'MTN': \r\n {\r\n 'CHGT_BUSE.gcode': '/MTN/CHGT_B~1.GCO', \r\n 'DEBOUCHAGE.gcode': '/MTN/DEBOUC~1.GCO', \r\n 'PRECHAUFFE.gcode': '/MTN/PRECHA~1.GCO'\r\n }, \r\n 'S2_V2IS': \r\n {\r\n '2h33m.bgcode': '/S2_V2IS/2H33M~1.BGC',\r\n '5h5m.bgcode': '/S2_V2IS/5H5M~1.BGC'\r\n }\r\n }\r\n\r\n## PrusaLinkPy.delete(remotePath) \r\n\r\nDelete a file or a folder on USB drive\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.delete('/DEBOUC~1.GCO')\r\n\r\n\r\n## PrusaLinkPy.post_gcode(remotePath) \r\n\r\nPrint a file already poresent on USB key \r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n obj = prusaMini.post_gcode('/DEBOUC~1.GCO')\r\n\r\n## PrusaLinkPy.put_gcode(remotePath, printAfterUpload = False, overwrite = False) \r\n\r\nSend a file on USB Drive.\r\n\r\nCan create a folder !\r\n\r\nif ret.status_code = 409 -> Conflict : File already exists\r\nif ret.status_code = 415 -> {\"title\": \"415: Unsupported Media Type\",\"message\":\"Not a GCODE\"}\r\n\r\nprintAfterUpload : Set at True to print after upload. \r\n\r\noverwrite : Allow file Overwrite\r\n\r\nFW 5.1.0 :\r\n\r\n * Warning: printing starts even if the bed is not empty\r\n * Can only send bgcode and gcode\r\n \r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n status = prusaMini.put('C:/MTN/DEBOUCHAGE.gcode' , 'MTN/DEBOUCHAGE.gcode')\r\n # Overwrite\r\n status = prusaMini.put('C:/MTN/DEBOUCHAGE.gcode' , 'MTN/DEBOUCHAGE.gcode', False, True)\r\n # Overwrite and Print\r\n status = prusaMini.put('C:/MTN/DEBOUCHAGE.gcode' , 'MTN/DEBOUCHAGE.gcode', True, True)\r\n \r\n## PrusaLinkPy.exists_gcode(remotePath) \r\n\r\nCheck if a file exists on USB drive. \r\n\r\nReturn True or False\r\n\r\n import PrusaLinkPy\r\n prusaMini = PrusaLinkPy.PrusaLinkPy(\"192.168.0.123\", \"8ojHKHGNuAHA2bM\")\r\n status = prusaMini.exists_gcode('/DEBOUC~1.GCO')\r\n\r\n## PrusaLinkPy.pause_print() \r\n\r\nPause actual print.\r\n\r\nAdded in 2.2.0 .\r\n\r\n## PrusaLinkPy.resume_print() \r\n\r\nResume paused print.\r\n\r\nAdded in 2.2.0 .\r\n\r\n## PrusaLinkPy.stop_print() \r\n\r\nStop actual print.\r\n\r\nAdded in 2.2.0 .\r\n\r\n# API\r\n\r\nAPI not implemented in my lib : \r\n\r\n * retrieve thumbnail :\r\n\r\n r = requests.get('http://192.168.0.123:8017/thumb/l/usb/TAVERN~1.GCO', headers=headers)\r\n\r\n/api/settings\r\n\r\n\r\nPOST /api/job\r\n**[Link to Buddy code](https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/lib/WUI/link_content/prusa_link_api.cpp#L276)**\r\n\r\nGET/POST /api/download \r\n**[Link to Buddy code](https://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/lib/WUI/link_content/prusa_link_api.cpp#L289)**\r\n\r\n\r\n# Bugs present in Prusa MINI printer firmware 4.4.1:\r\n\r\n * There is no possibility to have the list of folders present in a directory\r\n * Solved in firmware 5\r\n * You cannot upload a gcode in a subfolder of the USB key\r\n * Solved in firmware 5\r\n * When the printer detects the end of the filament and it displays \"Change Filament\" the telemetry information is no longer good. Here is the information returned by the printer in this case:\r\n \r\n 'telemetry': {'temp-bed': 0.0, 'temp-nozzle': 0.0, 'print-speed': 100, 'z-height': 0.0, 'material': '---'}\r\n \r\n * Still in the case of a filament change, the status information is incorrect:\r\n\r\n 'state': {'text': 'Operational', 'flags': {'operational': True, 'paused': False, 'printing': False, 'cancelling': False, 'pausing': False, 'sdReady': False, 'error': False, 'closedOnError': False, 'ready': True, 'busy': False}\r\n\r\n\r\n# Inspiration\r\n\r\nAn other lib : \r\n\r\nhttps://github.com/home-assistant-libs/PrusaLinkPy/blob/main/PrusaLinkPy/\r\n\r\n\r\nLes commandes dans la mini :\r\nhttps://github.com/prusa3d/Prusa-Firmware-Buddy/blob/master/lib/WUI/link_content/basic_gets.cpp\r\n\r\n\r\n\r\n# Construire la lib\r\n\r\n py -m build\r\n\r\nTo upload to testpi repo :\r\n\r\n py -m twine upload --repository testpi dist/*\r\n\r\nTo upload to pypi repo :\r\n\r\n py -m twine upload dist/*\r\n\r\n\r\nhttps://medium.com/analytics-vidhya/how-to-create-a-python-library-7d5aea80cc3f\r\n\r\n",
"bugtrack_url": null,
"license": "Copyright (c) 2023 Guillaume RICO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A library to interface with the PrusaLink API",
"version": "2.2.0",
"project_urls": {
"Bug Tracker": "https://github.com/guillaume-rico/PrusaLinkPy/issues",
"Homepage": "https://github.com/guillaume-rico/PrusaLinkPy",
"repository": "https://github.com/guillaume-rico/PrusaLinkPy.git"
},
"split_keywords": [
"prusalink",
" api",
" mini"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "118048f553026cbdb5a91970df9540a49556226d4b07b234426856632e160267",
"md5": "68eedefaefdc122edd0299dc34cd1795",
"sha256": "ef759b792a84adc8bb485042b234cf285cd290be585035528e423b92b145be22"
},
"downloads": -1,
"filename": "PrusaLinkPy-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "68eedefaefdc122edd0299dc34cd1795",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8759,
"upload_time": "2024-05-13T14:24:20",
"upload_time_iso_8601": "2024-05-13T14:24:20.300480Z",
"url": "https://files.pythonhosted.org/packages/11/80/48f553026cbdb5a91970df9540a49556226d4b07b234426856632e160267/PrusaLinkPy-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5e20147fb335a6887e94cd51cc87feb9b4a59eb1031149348e06631be72cce92",
"md5": "1db2336c56763a5dae2692bd4150cf4b",
"sha256": "9d6cc32ed6fbd50d86276554d426a9129859a22dec036dfff6c9a2bee2c2c846"
},
"downloads": -1,
"filename": "prusalinkpy-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "1db2336c56763a5dae2692bd4150cf4b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7911,
"upload_time": "2024-05-13T14:24:22",
"upload_time_iso_8601": "2024-05-13T14:24:22.331680Z",
"url": "https://files.pythonhosted.org/packages/5e/20/147fb335a6887e94cd51cc87feb9b4a59eb1031149348e06631be72cce92/prusalinkpy-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-13 14:24:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "guillaume-rico",
"github_project": "PrusaLinkPy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "prusalinkpy"
}