flashforge-python-api 1.5.0__py3-none-any.whl → 3.0.0__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 +337 -233
- flashforge/_removed.py +65 -0
- flashforge/api/__init__.py +12 -18
- flashforge/api/constants/__init__.py +11 -11
- flashforge/api/constants/commands.py +18 -15
- flashforge/api/constants/endpoints.py +11 -11
- flashforge/api/misc/__init__.py +8 -8
- flashforge/api/network/__init__.py +11 -11
- flashforge/api/network/utils.py +71 -71
- flashforge/backends/__init__.py +80 -0
- flashforge/backends/connect.py +275 -0
- flashforge/backends/creator5_backend.py +191 -0
- flashforge/backends/dual_api_backend.py +170 -0
- flashforge/backends/dual_api_models.py +145 -0
- flashforge/backends/http_core.py +431 -0
- flashforge/backends/http_printer_backend.py +254 -0
- flashforge/backends/legacy_backend.py +436 -0
- flashforge/backends/printer_backend.py +217 -0
- flashforge/backends/types.py +125 -0
- flashforge/capabilities/__init__.py +98 -0
- flashforge/capabilities/models.py +67 -0
- flashforge/capabilities/palettes/__init__.py +28 -0
- flashforge/capabilities/palettes/ad5x_palette.py +70 -0
- flashforge/capabilities/palettes/creator5_palette.py +78 -0
- flashforge/capabilities/palettes/palette.py +54 -0
- flashforge/{api/controls/creator5_palette.py → capabilities/palettes/palette_snap.py} +226 -258
- flashforge/capabilities/printer_capabilities.py +145 -0
- flashforge/capabilities/registry.py +125 -0
- flashforge/capabilities/resolve_model.py +61 -0
- flashforge/discovery/__init__.py +39 -39
- flashforge/discovery/discovery.py +730 -763
- flashforge/exceptions.py +90 -51
- flashforge/models/__init__.py +52 -55
- flashforge/models/machine_info.py +540 -543
- flashforge/{api/controls/info.py → models/machine_info_parser.py} +35 -242
- flashforge/models/responses.py +119 -254
- flashforge/status/__init__.py +43 -0
- flashforge/status/printer_snapshot.py +396 -0
- flashforge/tcp/__init__.py +55 -54
- flashforge/tcp/a3_client.py +427 -427
- flashforge/tcp/a4_client.py +304 -304
- flashforge/tcp/ff_client.py +609 -590
- flashforge/tcp/gcode/__init__.py +15 -13
- flashforge/tcp/gcode/a3_gcode_controller.py +109 -109
- flashforge/tcp/gcode/gcode_controller.py +292 -308
- flashforge/tcp/gcode/gcodes.py +81 -99
- flashforge/tcp/gcode/legacy_gcode_controller.py +56 -0
- flashforge/tcp/parsers/__init__.py +27 -27
- flashforge/tcp/parsers/endstop_status.py +248 -248
- flashforge/tcp/parsers/location_info.py +83 -83
- flashforge/tcp/parsers/print_status.py +180 -180
- flashforge/tcp/parsers/printer_info.py +146 -146
- flashforge/tcp/parsers/temp_info.py +218 -218
- flashforge/tcp/parsers/thumbnail_info.py +274 -274
- flashforge/tcp/tcp_client.py +52 -12
- flashforge/threemf/__init__.py +40 -0
- flashforge/threemf/parser.py +560 -0
- flashforge/threemf/warnings.py +58 -0
- flashforge_python_api-3.0.0.dist-info/METADATA +184 -0
- flashforge_python_api-3.0.0.dist-info/RECORD +69 -0
- {flashforge_python_api-1.5.0.dist-info → flashforge_python_api-3.0.0.dist-info}/WHEEL +1 -1
- {flashforge_python_api-1.5.0.dist-info → flashforge_python_api-3.0.0.dist-info}/licenses/LICENSE +21 -21
- flashforge/api/controls/__init__.py +0 -17
- flashforge/api/controls/control.py +0 -413
- flashforge/api/controls/files.py +0 -210
- flashforge/api/controls/job_control.py +0 -880
- flashforge/api/controls/temp_control.py +0 -309
- flashforge/client.py +0 -609
- flashforge_python_api-1.5.0.dist-info/METADATA +0 -152
- flashforge_python_api-1.5.0.dist-info/RECORD +0 -49
- {flashforge_python_api-1.5.0.dist-info → flashforge_python_api-3.0.0.dist-info}/entry_points.txt +0 -0
flashforge/exceptions.py
CHANGED
|
@@ -1,51 +1,90 @@
|
|
|
1
|
-
"""
|
|
2
|
-
FlashForge Python API - Exceptions
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from __future__ import annotations
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class FlashForgeError(Exception):
|
|
9
|
-
"""Base class for every error this library raises deliberately."""
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class FlashForgeResponseError(FlashForgeError):
|
|
13
|
-
"""
|
|
14
|
-
The printer answered, but the payload could not be understood.
|
|
15
|
-
|
|
16
|
-
This is deliberately distinct from a ``None`` return, which every HTTP
|
|
17
|
-
control method uses for "could not reach the printer / the printer refused
|
|
18
|
-
us". Collapsing the two is what made ff-5mp-hass#18 take three releases to
|
|
19
|
-
diagnose: a Creator 5 reporting ``chamberTemp: -108`` (the firmware's "no
|
|
20
|
-
chamber sensor" sentinel) surfaced in Home Assistant as ``cannot_connect``,
|
|
21
|
-
pointing the user at their network for a schema problem.
|
|
22
|
-
|
|
23
|
-
Raise this whenever the transport succeeded and the *content* was the
|
|
24
|
-
problem, so callers can tell the user something actionable.
|
|
25
|
-
"""
|
|
26
|
-
|
|
27
|
-
def __init__(
|
|
28
|
-
self,
|
|
29
|
-
message: str,
|
|
30
|
-
*,
|
|
31
|
-
endpoint: str | None = None,
|
|
32
|
-
cause: Exception | None = None,
|
|
33
|
-
) -> None:
|
|
34
|
-
"""
|
|
35
|
-
Args:
|
|
36
|
-
message: Human-readable description of what could not be parsed.
|
|
37
|
-
endpoint: The endpoint whose response failed, e.g. "/detail".
|
|
38
|
-
cause: The underlying validation/decode error, kept for logs.
|
|
39
|
-
"""
|
|
40
|
-
super().__init__(message)
|
|
41
|
-
self.message = message
|
|
42
|
-
self.endpoint = endpoint
|
|
43
|
-
self.cause = cause
|
|
44
|
-
|
|
45
|
-
def __str__(self) -> str:
|
|
46
|
-
parts = [self.message]
|
|
47
|
-
if self.endpoint:
|
|
48
|
-
parts.append(f"(endpoint: {self.endpoint})")
|
|
49
|
-
if self.cause:
|
|
50
|
-
parts.append(f"caused by {type(self.cause).__name__}: {self.cause}")
|
|
51
|
-
return " ".join(parts)
|
|
1
|
+
"""
|
|
2
|
+
FlashForge Python API - Exceptions
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FlashForgeError(Exception):
|
|
9
|
+
"""Base class for every error this library raises deliberately."""
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FlashForgeResponseError(FlashForgeError):
|
|
13
|
+
"""
|
|
14
|
+
The printer answered, but the payload could not be understood.
|
|
15
|
+
|
|
16
|
+
This is deliberately distinct from a ``None`` return, which every HTTP
|
|
17
|
+
control method uses for "could not reach the printer / the printer refused
|
|
18
|
+
us". Collapsing the two is what made ff-5mp-hass#18 take three releases to
|
|
19
|
+
diagnose: a Creator 5 reporting ``chamberTemp: -108`` (the firmware's "no
|
|
20
|
+
chamber sensor" sentinel) surfaced in Home Assistant as ``cannot_connect``,
|
|
21
|
+
pointing the user at their network for a schema problem.
|
|
22
|
+
|
|
23
|
+
Raise this whenever the transport succeeded and the *content* was the
|
|
24
|
+
problem, so callers can tell the user something actionable.
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
message: str,
|
|
30
|
+
*,
|
|
31
|
+
endpoint: str | None = None,
|
|
32
|
+
cause: Exception | None = None,
|
|
33
|
+
) -> None:
|
|
34
|
+
"""
|
|
35
|
+
Args:
|
|
36
|
+
message: Human-readable description of what could not be parsed.
|
|
37
|
+
endpoint: The endpoint whose response failed, e.g. "/detail".
|
|
38
|
+
cause: The underlying validation/decode error, kept for logs.
|
|
39
|
+
"""
|
|
40
|
+
super().__init__(message)
|
|
41
|
+
self.message = message
|
|
42
|
+
self.endpoint = endpoint
|
|
43
|
+
self.cause = cause
|
|
44
|
+
|
|
45
|
+
def __str__(self) -> str:
|
|
46
|
+
parts = [self.message]
|
|
47
|
+
if self.endpoint:
|
|
48
|
+
parts.append(f"(endpoint: {self.endpoint})")
|
|
49
|
+
if self.cause:
|
|
50
|
+
parts.append(f"caused by {type(self.cause).__name__}: {self.cause}")
|
|
51
|
+
return " ".join(parts)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class NotSupportedError(FlashForgeError):
|
|
55
|
+
"""
|
|
56
|
+
The connected printer cannot do this operation. A UI should have hidden it:
|
|
57
|
+
read ``backend.capabilities`` before it offers an operation.
|
|
58
|
+
"""
|
|
59
|
+
|
|
60
|
+
def __init__(self, operation: str, model: str, reason: str) -> None:
|
|
61
|
+
"""
|
|
62
|
+
Args:
|
|
63
|
+
operation: The operation that was called, for example ``set_chamber_temp``.
|
|
64
|
+
model: The model id of the connected printer.
|
|
65
|
+
reason: Plain-language reason.
|
|
66
|
+
"""
|
|
67
|
+
super().__init__(f"{operation} is not supported on this printer ({model}): {reason}")
|
|
68
|
+
self.operation = operation
|
|
69
|
+
self.model = model
|
|
70
|
+
self.reason = reason
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class InvalidParameterError(FlashForgeError, ValueError):
|
|
74
|
+
"""A parameter is out of range or has the wrong format. Nothing was sent to the printer."""
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class PrinterConnectionError(FlashForgeError):
|
|
78
|
+
"""
|
|
79
|
+
The connection could not be made. ``str(error)`` is a plain-language reason a UI can
|
|
80
|
+
show, for example a wrong check code or a printer that is not in LAN-only mode.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
def __init__(self, message: str, code: int | None = None) -> None:
|
|
84
|
+
"""
|
|
85
|
+
Args:
|
|
86
|
+
message: Plain-language reason.
|
|
87
|
+
code: The ``/detail`` response code when the printer rejected the request.
|
|
88
|
+
"""
|
|
89
|
+
super().__init__(message)
|
|
90
|
+
self.code = code
|
flashforge/models/__init__.py
CHANGED
|
@@ -1,55 +1,52 @@
|
|
|
1
|
-
"""
|
|
2
|
-
FlashForge Python API - Models Package
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from .machine_info import (
|
|
6
|
-
FFGcodeFileEntry,
|
|
7
|
-
FFGcodeToolData,
|
|
8
|
-
FFMachineInfo,
|
|
9
|
-
FFPrinterDetail,
|
|
10
|
-
IndepMatlInfo,
|
|
11
|
-
MachineState,
|
|
12
|
-
MatlStationInfo,
|
|
13
|
-
SlotInfo,
|
|
14
|
-
Temperature,
|
|
15
|
-
)
|
|
16
|
-
from .
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"GCodeListResponse",
|
|
54
|
-
"ThumbnailResponse",
|
|
55
|
-
]
|
|
1
|
+
"""
|
|
2
|
+
FlashForge Python API - Models Package
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .machine_info import (
|
|
6
|
+
FFGcodeFileEntry,
|
|
7
|
+
FFGcodeToolData,
|
|
8
|
+
FFMachineInfo,
|
|
9
|
+
FFPrinterDetail,
|
|
10
|
+
IndepMatlInfo,
|
|
11
|
+
MachineState,
|
|
12
|
+
MatlStationInfo,
|
|
13
|
+
SlotInfo,
|
|
14
|
+
Temperature,
|
|
15
|
+
)
|
|
16
|
+
from .machine_info_parser import MachineInfoParser
|
|
17
|
+
from .responses import (
|
|
18
|
+
DetailResponse,
|
|
19
|
+
FilamentArgs,
|
|
20
|
+
GCodeListResponse,
|
|
21
|
+
GenericResponse,
|
|
22
|
+
Product,
|
|
23
|
+
ProductResponse,
|
|
24
|
+
ThumbnailResponse,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
__all__ = [
|
|
28
|
+
"MachineInfoParser",
|
|
29
|
+
"FFMachineInfo",
|
|
30
|
+
"FFPrinterDetail",
|
|
31
|
+
"FFGcodeFileEntry",
|
|
32
|
+
"FFGcodeToolData",
|
|
33
|
+
"MachineState",
|
|
34
|
+
"Temperature",
|
|
35
|
+
"SlotInfo",
|
|
36
|
+
"MatlStationInfo",
|
|
37
|
+
"IndepMatlInfo",
|
|
38
|
+
"DetailResponse",
|
|
39
|
+
"FilamentArgs",
|
|
40
|
+
"GenericResponse",
|
|
41
|
+
"Product",
|
|
42
|
+
"ProductResponse",
|
|
43
|
+
"GCodeListResponse",
|
|
44
|
+
"ThumbnailResponse",
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def __getattr__(name: str) -> object:
|
|
49
|
+
"""Raise a clear error for names removed in 3.0 (see ``flashforge._removed``)."""
|
|
50
|
+
from .._removed import REMOVED_MODELS, module_getattr
|
|
51
|
+
|
|
52
|
+
return module_getattr(__name__, REMOVED_MODELS, name)
|