flashforge-python-api 1.3.2__py3-none-any.whl → 1.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flashforge/__init__.py +5 -1
- flashforge/api/controls/control.py +16 -9
- flashforge/api/controls/creator5_palette.py +6 -3
- flashforge/api/controls/files.py +10 -4
- flashforge/api/controls/info.py +123 -21
- flashforge/api/controls/job_control.py +106 -68
- flashforge/api/controls/temp_control.py +15 -6
- flashforge/api/misc/redaction.py +88 -0
- flashforge/client.py +9 -9
- flashforge/exceptions.py +51 -0
- flashforge/models/machine_info.py +196 -99
- flashforge/tcp/parsers/endstop_status.py +7 -5
- flashforge/tcp/parsers/print_status.py +5 -2
- flashforge/tcp/parsers/thumbnail_info.py +18 -11
- {flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/METADATA +1 -1
- {flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/RECORD +19 -17
- {flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/WHEEL +0 -0
- {flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/entry_points.txt +0 -0
- {flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -6,9 +6,12 @@ Handles the parsing, storage, and manipulation of 3D print file thumbnail images
|
|
|
6
6
|
|
|
7
7
|
import asyncio
|
|
8
8
|
import base64
|
|
9
|
+
import logging
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import Optional
|
|
11
12
|
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
class ThumbnailInfo:
|
|
14
17
|
"""
|
|
@@ -65,7 +68,7 @@ class ThumbnailInfo:
|
|
|
65
68
|
# Find where the PNG data starts (after the "ok" text delimiter)
|
|
66
69
|
ok_index = replay.find("ok")
|
|
67
70
|
if ok_index == -1:
|
|
68
|
-
|
|
71
|
+
logger.warning("ThumbnailInfo: no 'ok' delimiter found in the response.")
|
|
69
72
|
return None
|
|
70
73
|
|
|
71
74
|
# Skip the 'ok' text and any immediately following control characters
|
|
@@ -87,11 +90,11 @@ class ThumbnailInfo:
|
|
|
87
90
|
self._image_data = binary_buffer[png_start:]
|
|
88
91
|
return self
|
|
89
92
|
else:
|
|
90
|
-
|
|
93
|
+
logger.warning("ThumbnailInfo: no PNG signature found in the binary data.")
|
|
91
94
|
return None
|
|
92
95
|
|
|
93
96
|
except Exception as e:
|
|
94
|
-
|
|
97
|
+
logger.warning("ThumbnailInfo: error parsing the response: %s", e)
|
|
95
98
|
return None
|
|
96
99
|
|
|
97
100
|
def get_image_data(self) -> str | None:
|
|
@@ -157,7 +160,7 @@ class ThumbnailInfo:
|
|
|
157
160
|
True if the file was saved successfully, False otherwise
|
|
158
161
|
"""
|
|
159
162
|
if not self._image_data:
|
|
160
|
-
|
|
163
|
+
logger.warning("ThumbnailInfo: no image data to save.")
|
|
161
164
|
return False
|
|
162
165
|
|
|
163
166
|
try:
|
|
@@ -169,18 +172,20 @@ class ThumbnailInfo:
|
|
|
169
172
|
file_path = f"{base_name}.png"
|
|
170
173
|
|
|
171
174
|
if not file_path:
|
|
172
|
-
|
|
175
|
+
logger.warning(
|
|
176
|
+
"ThumbnailInfo: no file path provided and no filename to generate one from."
|
|
177
|
+
)
|
|
173
178
|
return False
|
|
174
179
|
|
|
175
180
|
# Write the bytes to file in a separate thread to avoid blocking the event loop
|
|
176
181
|
loop = asyncio.get_running_loop()
|
|
177
182
|
await loop.run_in_executor(None, self._write_file_sync, file_path, self._image_data)
|
|
178
183
|
|
|
179
|
-
|
|
184
|
+
logger.debug("ThumbnailInfo: saved the thumbnail to %s", file_path)
|
|
180
185
|
return True
|
|
181
186
|
|
|
182
187
|
except Exception as e:
|
|
183
|
-
|
|
188
|
+
logger.warning("ThumbnailInfo: error saving the thumbnail to a file: %s", e)
|
|
184
189
|
return False
|
|
185
190
|
|
|
186
191
|
def save_to_file_sync(self, file_path: str | None = None) -> bool:
|
|
@@ -194,7 +199,7 @@ class ThumbnailInfo:
|
|
|
194
199
|
True if the file was saved successfully, False otherwise
|
|
195
200
|
"""
|
|
196
201
|
if not self._image_data:
|
|
197
|
-
|
|
202
|
+
logger.warning("ThumbnailInfo: no image data to save.")
|
|
198
203
|
return False
|
|
199
204
|
|
|
200
205
|
try:
|
|
@@ -206,18 +211,20 @@ class ThumbnailInfo:
|
|
|
206
211
|
file_path = f"{base_name}.png"
|
|
207
212
|
|
|
208
213
|
if not file_path:
|
|
209
|
-
|
|
214
|
+
logger.warning(
|
|
215
|
+
"ThumbnailInfo: no file path provided and no filename to generate one from."
|
|
216
|
+
)
|
|
210
217
|
return False
|
|
211
218
|
|
|
212
219
|
# Write the bytes to file
|
|
213
220
|
with open(file_path, "wb") as f:
|
|
214
221
|
f.write(self._image_data)
|
|
215
222
|
|
|
216
|
-
|
|
223
|
+
logger.debug("ThumbnailInfo: saved the thumbnail to %s", file_path)
|
|
217
224
|
return True
|
|
218
225
|
|
|
219
226
|
except Exception as e:
|
|
220
|
-
|
|
227
|
+
logger.warning("ThumbnailInfo: error saving the thumbnail to a file: %s", e)
|
|
221
228
|
return False
|
|
222
229
|
|
|
223
230
|
def get_image_size(self) -> tuple[int, int]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: flashforge-python-api
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.4
|
|
4
4
|
Summary: A comprehensive Python library for controlling FlashForge 3D printers
|
|
5
5
|
Project-URL: Homepage, https://github.com/GhostTypes/ff-5mp-api-py
|
|
6
6
|
Project-URL: Documentation, https://github.com/GhostTypes/ff-5mp-api-py#readme
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
flashforge/__init__.py,sha256=
|
|
2
|
-
flashforge/client.py,sha256=
|
|
1
|
+
flashforge/__init__.py,sha256=pTj91BlyK6rFMy9yD03q8IowcSrUm9ra-b1vMCYEJDo,5472
|
|
2
|
+
flashforge/client.py,sha256=nDtnv3y9XlEQknIkgIUiuOYAiyTEGbQ7tHBdCs2fg1I,21432
|
|
3
|
+
flashforge/exceptions.py,sha256=rZwBJHyqqtoI6cgd8iGOvPH8EDcytA3lyU3FoVMJgyU,1732
|
|
3
4
|
flashforge/api/__init__.py,sha256=vQz-DkG6LTH39bI4fyiUc0D9jQzemLh45pORLptSOlg,335
|
|
4
5
|
flashforge/api/constants/__init__.py,sha256=Q0HL2tqSBYPd4Oz49VHLS3qUvRuv__GCvTGecaLrQ-Y,163
|
|
5
6
|
flashforge/api/constants/commands.py,sha256=XM2rooBESPDaywlZrfW2ECTaLLFaSKXkJ7FQ-RBmVdY,578
|
|
6
7
|
flashforge/api/constants/endpoints.py,sha256=oZtOFfkU64THDeCMUIVv6_0L-BOUZzgLKAUfjHkUhi8,337
|
|
7
8
|
flashforge/api/controls/__init__.py,sha256=53s-H25Pjwr0kvPk8MZ2Twy8VHGqGcO6Q6uBphhEOh4,293
|
|
8
|
-
flashforge/api/controls/control.py,sha256=
|
|
9
|
-
flashforge/api/controls/creator5_palette.py,sha256=
|
|
10
|
-
flashforge/api/controls/files.py,sha256=
|
|
11
|
-
flashforge/api/controls/info.py,sha256=
|
|
12
|
-
flashforge/api/controls/job_control.py,sha256=
|
|
13
|
-
flashforge/api/controls/temp_control.py,sha256=
|
|
9
|
+
flashforge/api/controls/control.py,sha256=OgE7K6NkFLwFN1r_q5g1RPwYC8MCt0f6L5CZxDW44d8,15151
|
|
10
|
+
flashforge/api/controls/creator5_palette.py,sha256=zdD3PIXx7hCVj2Fmv1CSFOaqogRUPeBaymgY2DFiMxk,8835
|
|
11
|
+
flashforge/api/controls/files.py,sha256=25yxln9NROas9TtFMZR9e8LtA8ruk8RUu2C81vpNgTk,8043
|
|
12
|
+
flashforge/api/controls/info.py,sha256=AZ5529HbB1LBfae6voz_4mz30pQd8R8HpcRrPa5qXCw,22451
|
|
13
|
+
flashforge/api/controls/job_control.py,sha256=NnACm4LPUz4n8lnRiUl33jilWekS1b6HQTbP--nDzZc,33225
|
|
14
|
+
flashforge/api/controls/temp_control.py,sha256=EOO5TkODirjFcnQ7rZrirxAweHBdVin032AWj-Z8VQs,13040
|
|
14
15
|
flashforge/api/filament/__init__.py,sha256=isT2dl0hzUS0xMTXMm4Tip0GTG1gCsm8LKWa9xPu4Y8,104
|
|
15
16
|
flashforge/api/filament/filament.py,sha256=TtcC2G2nD9Sq4cOrCZzFLZ6Q0Ve-zfrfuEF9uQ8M3eE,1214
|
|
16
17
|
flashforge/api/misc/__init__.py,sha256=1AG7vOMRBZQtHp6QUzfr9alcJPeNv3JpU44NrznxDHs,211
|
|
18
|
+
flashforge/api/misc/redaction.py,sha256=8LG2WsFXhdBqbZ4AXYwpm8hQ_PxaOeAKmZBeG5kzAT4,2675
|
|
17
19
|
flashforge/api/misc/scientific_notation.py,sha256=KSMTrrYhPWLv0gbcEAD6u-jEOcIwUjOCOPMBi0LiO-k,826
|
|
18
20
|
flashforge/api/misc/temperature.py,sha256=qeHlCdPzLyqGDEB874Ib5AgYHMR9Qtw61shnw4G095E,1066
|
|
19
21
|
flashforge/api/network/__init__.py,sha256=G5fBoAlq-NQPDkWp579mFIqsj0v7B1Lb2TAzO6IZA0Q,164
|
|
@@ -22,7 +24,7 @@ flashforge/api/network/utils.py,sha256=Q5-Vj_1VN611QV_TGpDzrrZ2X8PqaGT0j00BhSHv5
|
|
|
22
24
|
flashforge/discovery/__init__.py,sha256=G0WiP70EhfHdjXR1RNlv6xjhyHOdo-HWyOm9J0ds4SM,828
|
|
23
25
|
flashforge/discovery/discovery.py,sha256=-hOmVIpn8gu-rPYo8FRBfhKb_tBqwamLfmoPVYaDzLI,27614
|
|
24
26
|
flashforge/models/__init__.py,sha256=hdcK0E4KeDfv_A8Y2aPOHgHziwTjP1RPb_VP-89dOzQ,1086
|
|
25
|
-
flashforge/models/machine_info.py,sha256=
|
|
27
|
+
flashforge/models/machine_info.py,sha256=o0rpT6DPWojg8VMfYleMFIqEaidDvsY6E0MstaVHOT0,24065
|
|
26
28
|
flashforge/models/responses.py,sha256=10-8yFfZtLuDmH1TK2xVYl-Uf-zT2WEJnpb2H5ZK3ZU,10637
|
|
27
29
|
flashforge/tcp/__init__.py,sha256=hpnqoWHeRtTwJPzdsVlwGt1njKbAkrgIHKADkLSIRec,1317
|
|
28
30
|
flashforge/tcp/a3_client.py,sha256=Aqb6MuKkjnNUVdE2LbZKd7bPlFK8XPIm17C_BG_PuNU,15867
|
|
@@ -34,14 +36,14 @@ flashforge/tcp/gcode/a3_gcode_controller.py,sha256=x84_xo_Ll5k6hMAwDWuNUo54znV-B
|
|
|
34
36
|
flashforge/tcp/gcode/gcode_controller.py,sha256=6K1VGgX59AcE_Kh_gm13dmxCY_kuzV_d2ooSpheONRI,10075
|
|
35
37
|
flashforge/tcp/gcode/gcodes.py,sha256=55Ii1JpJNJNmOnBivyF83vz3TZUPDtp01lX72NINfPQ,3658
|
|
36
38
|
flashforge/tcp/parsers/__init__.py,sha256=kDaJmiH0JcR5i693Fj3pwmINLWN0ipirN3LWGFvPst0,730
|
|
37
|
-
flashforge/tcp/parsers/endstop_status.py,sha256=
|
|
39
|
+
flashforge/tcp/parsers/endstop_status.py,sha256=k7C5P_TiKlqBxSq2ybRoBDaaDcQ_EgiZe2NLYo7ubiE,9902
|
|
38
40
|
flashforge/tcp/parsers/location_info.py,sha256=0fbqCmQ2EQQe8z9fiX0zP1YsnuVayTs81zmF3_HuGZM,2895
|
|
39
|
-
flashforge/tcp/parsers/print_status.py,sha256=
|
|
41
|
+
flashforge/tcp/parsers/print_status.py,sha256=C-KzukhK0TR86AP3t3XrMH4dief6pa3I-yiST4rL0mk,6271
|
|
40
42
|
flashforge/tcp/parsers/printer_info.py,sha256=CHPs6nJfEByXyG3co7Nb8_ygggxkYuc7A9O9bpQEqXE,5441
|
|
41
43
|
flashforge/tcp/parsers/temp_info.py,sha256=9wRGUM9cKvDiZD3SIxBx_qVLZbeXoYsoY3-R3vN3H4g,7938
|
|
42
|
-
flashforge/tcp/parsers/thumbnail_info.py,sha256=
|
|
43
|
-
flashforge_python_api-1.3.
|
|
44
|
-
flashforge_python_api-1.3.
|
|
45
|
-
flashforge_python_api-1.3.
|
|
46
|
-
flashforge_python_api-1.3.
|
|
47
|
-
flashforge_python_api-1.3.
|
|
44
|
+
flashforge/tcp/parsers/thumbnail_info.py,sha256=1U1S_gcIZ2lDpEA4622ywUew6TVw0BnzjlBAiihQwzk,10478
|
|
45
|
+
flashforge_python_api-1.3.4.dist-info/METADATA,sha256=Kdqkl6GJBRr3vRFf6p6Qk-qZ_8TtSUCNS0jdzEIxvHE,4970
|
|
46
|
+
flashforge_python_api-1.3.4.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
|
|
47
|
+
flashforge_python_api-1.3.4.dist-info/entry_points.txt,sha256=AkOxlsLvQ7cvMLxn7tlzfKp_DCH2hXhbVceHIXxawpU,66
|
|
48
|
+
flashforge_python_api-1.3.4.dist-info/licenses/LICENSE,sha256=-cTA-hrmvlb3pqlQrBZQXUnKayhUjsLJMPb7TD91frM,1067
|
|
49
|
+
flashforge_python_api-1.3.4.dist-info/RECORD,,
|
|
File without changes
|
{flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{flashforge_python_api-1.3.2.dist-info → flashforge_python_api-1.3.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|