flashforge-python-api 1.6.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.
Files changed (70) hide show
  1. flashforge/__init__.py +337 -256
  2. flashforge/_removed.py +65 -0
  3. flashforge/api/__init__.py +12 -18
  4. flashforge/api/constants/__init__.py +11 -11
  5. flashforge/api/constants/commands.py +18 -15
  6. flashforge/api/constants/endpoints.py +11 -11
  7. flashforge/api/misc/__init__.py +8 -8
  8. flashforge/api/network/__init__.py +11 -11
  9. flashforge/api/network/utils.py +71 -71
  10. flashforge/backends/__init__.py +80 -0
  11. flashforge/backends/connect.py +275 -0
  12. flashforge/backends/creator5_backend.py +191 -0
  13. flashforge/backends/dual_api_backend.py +170 -0
  14. flashforge/backends/dual_api_models.py +145 -0
  15. flashforge/backends/http_core.py +431 -0
  16. flashforge/backends/http_printer_backend.py +254 -0
  17. flashforge/backends/legacy_backend.py +436 -0
  18. flashforge/backends/printer_backend.py +217 -0
  19. flashforge/backends/types.py +125 -0
  20. flashforge/capabilities/__init__.py +98 -0
  21. flashforge/capabilities/models.py +67 -0
  22. flashforge/capabilities/palettes/__init__.py +28 -0
  23. flashforge/capabilities/palettes/ad5x_palette.py +70 -0
  24. flashforge/capabilities/palettes/creator5_palette.py +78 -0
  25. flashforge/capabilities/palettes/palette.py +54 -0
  26. flashforge/{api/controls/creator5_palette.py → capabilities/palettes/palette_snap.py} +226 -258
  27. flashforge/capabilities/printer_capabilities.py +145 -0
  28. flashforge/capabilities/registry.py +125 -0
  29. flashforge/capabilities/resolve_model.py +61 -0
  30. flashforge/discovery/__init__.py +39 -39
  31. flashforge/discovery/discovery.py +730 -763
  32. flashforge/exceptions.py +90 -51
  33. flashforge/models/__init__.py +52 -55
  34. flashforge/models/machine_info.py +540 -543
  35. flashforge/{api/controls/info.py → models/machine_info_parser.py} +35 -242
  36. flashforge/models/responses.py +119 -254
  37. flashforge/status/__init__.py +43 -0
  38. flashforge/status/printer_snapshot.py +396 -0
  39. flashforge/tcp/__init__.py +55 -54
  40. flashforge/tcp/a3_client.py +427 -427
  41. flashforge/tcp/a4_client.py +304 -304
  42. flashforge/tcp/ff_client.py +609 -590
  43. flashforge/tcp/gcode/__init__.py +15 -13
  44. flashforge/tcp/gcode/a3_gcode_controller.py +109 -109
  45. flashforge/tcp/gcode/gcode_controller.py +292 -308
  46. flashforge/tcp/gcode/gcodes.py +81 -99
  47. flashforge/tcp/gcode/legacy_gcode_controller.py +56 -0
  48. flashforge/tcp/parsers/__init__.py +27 -27
  49. flashforge/tcp/parsers/endstop_status.py +248 -248
  50. flashforge/tcp/parsers/location_info.py +83 -83
  51. flashforge/tcp/parsers/print_status.py +180 -180
  52. flashforge/tcp/parsers/printer_info.py +146 -146
  53. flashforge/tcp/parsers/temp_info.py +218 -218
  54. flashforge/tcp/parsers/thumbnail_info.py +274 -274
  55. flashforge/tcp/tcp_client.py +52 -12
  56. flashforge/threemf/__init__.py +40 -40
  57. flashforge/threemf/parser.py +560 -560
  58. flashforge/threemf/warnings.py +58 -58
  59. {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/METADATA +46 -47
  60. flashforge_python_api-3.0.0.dist-info/RECORD +69 -0
  61. {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/WHEEL +1 -1
  62. {flashforge_python_api-1.6.0.dist-info → flashforge_python_api-3.0.0.dist-info}/licenses/LICENSE +21 -21
  63. flashforge/api/controls/__init__.py +0 -17
  64. flashforge/api/controls/control.py +0 -413
  65. flashforge/api/controls/files.py +0 -210
  66. flashforge/api/controls/job_control.py +0 -896
  67. flashforge/api/controls/temp_control.py +0 -309
  68. flashforge/client.py +0 -609
  69. flashforge_python_api-1.6.0.dist-info/RECORD +0 -52
  70. {flashforge_python_api-1.6.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
@@ -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 .responses import (
17
- AD5XLocalJobParams,
18
- AD5XMaterialMapping,
19
- AD5XSingleColorJobParams,
20
- AD5XUploadParams,
21
- Creator5JobParams,
22
- Creator5UploadParams,
23
- DetailResponse,
24
- FilamentArgs,
25
- GCodeListResponse,
26
- GenericResponse,
27
- Product,
28
- ProductResponse,
29
- ThumbnailResponse,
30
- )
31
-
32
- __all__ = [
33
- "FFMachineInfo",
34
- "FFPrinterDetail",
35
- "FFGcodeFileEntry",
36
- "FFGcodeToolData",
37
- "MachineState",
38
- "Temperature",
39
- "SlotInfo",
40
- "MatlStationInfo",
41
- "IndepMatlInfo",
42
- "DetailResponse",
43
- "FilamentArgs",
44
- "GenericResponse",
45
- "Product",
46
- "ProductResponse",
47
- "AD5XMaterialMapping",
48
- "AD5XLocalJobParams",
49
- "AD5XSingleColorJobParams",
50
- "AD5XUploadParams",
51
- "Creator5JobParams",
52
- "Creator5UploadParams",
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)