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/__init__.py
CHANGED
|
@@ -1,233 +1,337 @@
|
|
|
1
|
-
"""
|
|
2
|
-
FlashForge Python API
|
|
3
|
-
|
|
4
|
-
A Python library for controlling FlashForge 3D printers
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
"
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"
|
|
192
|
-
"
|
|
193
|
-
"
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
"
|
|
198
|
-
"
|
|
199
|
-
"
|
|
200
|
-
|
|
201
|
-
"
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
"
|
|
207
|
-
"
|
|
208
|
-
"
|
|
209
|
-
"
|
|
210
|
-
"
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
"
|
|
214
|
-
|
|
215
|
-
"
|
|
216
|
-
"
|
|
217
|
-
"
|
|
218
|
-
"
|
|
219
|
-
"
|
|
220
|
-
"
|
|
221
|
-
"
|
|
222
|
-
|
|
223
|
-
"
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
"
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
1
|
+
"""
|
|
2
|
+
FlashForge Python API
|
|
3
|
+
|
|
4
|
+
A Python library for controlling FlashForge 3D printers over their HTTP and TCP APIs.
|
|
5
|
+
Each printer family has its own backend; :func:`connect_printer` picks the right one.
|
|
6
|
+
|
|
7
|
+
Example:
|
|
8
|
+
```python
|
|
9
|
+
import asyncio
|
|
10
|
+
from flashforge import ConnectOptions, ConnectTarget, PrinterDiscovery, connect_printer
|
|
11
|
+
|
|
12
|
+
async def main():
|
|
13
|
+
printers = await PrinterDiscovery().discover()
|
|
14
|
+
backend = await connect_printer(printers[0], ConnectOptions(check_code="12345678"))
|
|
15
|
+
async with backend:
|
|
16
|
+
status = await backend.get_status()
|
|
17
|
+
print(status.state, status.temperatures.extruder.current)
|
|
18
|
+
if backend.capabilities.led.controllable:
|
|
19
|
+
await backend.set_led(True)
|
|
20
|
+
|
|
21
|
+
asyncio.run(main())
|
|
22
|
+
```
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from .api.constants.commands import Commands
|
|
26
|
+
from .api.constants.endpoints import Endpoints
|
|
27
|
+
from .api.filament import Filament
|
|
28
|
+
from .api.misc import Temperature as TempWrapper
|
|
29
|
+
from .api.misc import format_scientific_notation
|
|
30
|
+
from .api.network.fnet_code import FNetCode
|
|
31
|
+
|
|
32
|
+
# Import utility classes
|
|
33
|
+
from .api.network.utils import NetworkUtils
|
|
34
|
+
from .backends import (
|
|
35
|
+
AD5XBackend,
|
|
36
|
+
Adventurer5MBackend,
|
|
37
|
+
Adventurer5MProBackend,
|
|
38
|
+
ConnectOptions,
|
|
39
|
+
ConnectTarget,
|
|
40
|
+
Creator5Backend,
|
|
41
|
+
DualApiBackend,
|
|
42
|
+
FiltrationMode,
|
|
43
|
+
HttpCore,
|
|
44
|
+
HttpPrinterBackend,
|
|
45
|
+
LegacyBackend,
|
|
46
|
+
LocalJobParams,
|
|
47
|
+
MaterialMapping,
|
|
48
|
+
PrinterBackend,
|
|
49
|
+
PrinterIdentity,
|
|
50
|
+
PrintOverrides,
|
|
51
|
+
SlotAction,
|
|
52
|
+
UploadJobParams,
|
|
53
|
+
connect_printer,
|
|
54
|
+
)
|
|
55
|
+
from .capabilities import (
|
|
56
|
+
AD5X_FILAMENT_PALETTE,
|
|
57
|
+
AD5X_MATERIALS,
|
|
58
|
+
AD5X_PALETTE,
|
|
59
|
+
CREATOR5_FILAMENT_PALETTE,
|
|
60
|
+
CREATOR5_MATERIALS,
|
|
61
|
+
CREATOR5_PALETTE,
|
|
62
|
+
BackendFamily,
|
|
63
|
+
FeatureSupport,
|
|
64
|
+
LedSupport,
|
|
65
|
+
MaterialStationSupport,
|
|
66
|
+
Palette,
|
|
67
|
+
PaletteColor,
|
|
68
|
+
PrinterCapabilities,
|
|
69
|
+
get_model_palette,
|
|
70
|
+
get_palette_for_model,
|
|
71
|
+
resolve_capabilities,
|
|
72
|
+
resolve_model,
|
|
73
|
+
snap_to_ad5x_palette,
|
|
74
|
+
snap_to_creator5_palette,
|
|
75
|
+
snap_to_model_palette,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Import discovery classes
|
|
79
|
+
from .discovery import (
|
|
80
|
+
DiscoveredPrinter,
|
|
81
|
+
DiscoveryError,
|
|
82
|
+
DiscoveryMonitor,
|
|
83
|
+
DiscoveryOptions,
|
|
84
|
+
DiscoveryProtocol,
|
|
85
|
+
DiscoveryTimeoutError,
|
|
86
|
+
FlashForgePrinter,
|
|
87
|
+
FlashForgePrinterDiscovery,
|
|
88
|
+
InvalidResponseError,
|
|
89
|
+
PrinterDiscovery,
|
|
90
|
+
PrinterModelId,
|
|
91
|
+
PrinterStatus,
|
|
92
|
+
SocketCreationError,
|
|
93
|
+
)
|
|
94
|
+
from .exceptions import (
|
|
95
|
+
FlashForgeError,
|
|
96
|
+
FlashForgeResponseError,
|
|
97
|
+
InvalidParameterError,
|
|
98
|
+
NotSupportedError,
|
|
99
|
+
PrinterConnectionError,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# Import key models for convenience
|
|
103
|
+
from .models import (
|
|
104
|
+
DetailResponse,
|
|
105
|
+
FFGcodeFileEntry,
|
|
106
|
+
FFGcodeToolData,
|
|
107
|
+
FFMachineInfo,
|
|
108
|
+
FFPrinterDetail,
|
|
109
|
+
FilamentArgs,
|
|
110
|
+
GCodeListResponse,
|
|
111
|
+
GenericResponse,
|
|
112
|
+
IndepMatlInfo,
|
|
113
|
+
MachineInfoParser,
|
|
114
|
+
MachineState,
|
|
115
|
+
MatlStationInfo,
|
|
116
|
+
Product,
|
|
117
|
+
ProductResponse,
|
|
118
|
+
SlotInfo,
|
|
119
|
+
Temperature,
|
|
120
|
+
ThumbnailResponse,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
# Sliced 3MF parsing (tools and materials before upload)
|
|
124
|
+
from .status import (
|
|
125
|
+
JobProgress,
|
|
126
|
+
JobSnapshot,
|
|
127
|
+
MaterialSlotSnapshot,
|
|
128
|
+
MaterialStationSnapshot,
|
|
129
|
+
PrinterRunState,
|
|
130
|
+
PrinterSnapshot,
|
|
131
|
+
TemperatureReading,
|
|
132
|
+
)
|
|
133
|
+
from .tcp import (
|
|
134
|
+
A3BuildVolume,
|
|
135
|
+
A3FileEntry,
|
|
136
|
+
A3GCodeController,
|
|
137
|
+
A3PrinterInfo,
|
|
138
|
+
A3Thumbnail,
|
|
139
|
+
A4BuildVolume,
|
|
140
|
+
A4FileEntry,
|
|
141
|
+
A4PrinterInfo,
|
|
142
|
+
Endstop,
|
|
143
|
+
EndstopStatus,
|
|
144
|
+
FlashForgeA3Client,
|
|
145
|
+
FlashForgeA4Client,
|
|
146
|
+
FlashForgeTcpClient,
|
|
147
|
+
FlashForgeTcpClientOptions,
|
|
148
|
+
GCodeController,
|
|
149
|
+
GCodes,
|
|
150
|
+
LegacyGCodeController,
|
|
151
|
+
LocationInfo,
|
|
152
|
+
MachineStatus,
|
|
153
|
+
MoveMode,
|
|
154
|
+
PrinterInfo,
|
|
155
|
+
PrintStatus,
|
|
156
|
+
Status,
|
|
157
|
+
TempData,
|
|
158
|
+
TempInfo,
|
|
159
|
+
ThumbnailInfo,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Import TCP classes for low-level access
|
|
163
|
+
from .tcp import (
|
|
164
|
+
FlashForgeTcpClient as TcpClient,
|
|
165
|
+
)
|
|
166
|
+
from .threemf import (
|
|
167
|
+
PrinterFamily,
|
|
168
|
+
ThreeMFError,
|
|
169
|
+
ThreeMFFilament,
|
|
170
|
+
ThreeMFFile,
|
|
171
|
+
ThreeMFFormatError,
|
|
172
|
+
ThreeMFMultiplePlatesError,
|
|
173
|
+
ThreeMFNotSlicedError,
|
|
174
|
+
ThreeMFWarning,
|
|
175
|
+
parse_3mf,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
__version__ = "3.0.0"
|
|
179
|
+
__author__ = "FlashForge Python API Contributors"
|
|
180
|
+
__email__ = "notghosttypes@gmail.com"
|
|
181
|
+
__description__ = "Python library for controlling FlashForge 3D printers"
|
|
182
|
+
|
|
183
|
+
# Public API - Main classes most users will need
|
|
184
|
+
__all__ = [
|
|
185
|
+
# Backends and the connect factory
|
|
186
|
+
"connect_printer",
|
|
187
|
+
"ConnectOptions",
|
|
188
|
+
"ConnectTarget",
|
|
189
|
+
"PrinterBackend",
|
|
190
|
+
"PrinterIdentity",
|
|
191
|
+
"HttpCore",
|
|
192
|
+
"HttpPrinterBackend",
|
|
193
|
+
"DualApiBackend",
|
|
194
|
+
"Adventurer5MBackend",
|
|
195
|
+
"Adventurer5MProBackend",
|
|
196
|
+
"AD5XBackend",
|
|
197
|
+
"Creator5Backend",
|
|
198
|
+
"LegacyBackend",
|
|
199
|
+
"UploadJobParams",
|
|
200
|
+
"LocalJobParams",
|
|
201
|
+
"MaterialMapping",
|
|
202
|
+
"PrintOverrides",
|
|
203
|
+
"FiltrationMode",
|
|
204
|
+
"SlotAction",
|
|
205
|
+
# Capabilities and palettes
|
|
206
|
+
"BackendFamily",
|
|
207
|
+
"FeatureSupport",
|
|
208
|
+
"LedSupport",
|
|
209
|
+
"MaterialStationSupport",
|
|
210
|
+
"PrinterCapabilities",
|
|
211
|
+
"PrinterModelId",
|
|
212
|
+
"resolve_capabilities",
|
|
213
|
+
"resolve_model",
|
|
214
|
+
"PaletteColor",
|
|
215
|
+
"AD5X_PALETTE",
|
|
216
|
+
"AD5X_MATERIALS",
|
|
217
|
+
"CREATOR5_PALETTE",
|
|
218
|
+
"CREATOR5_MATERIALS",
|
|
219
|
+
"AD5X_FILAMENT_PALETTE",
|
|
220
|
+
"CREATOR5_FILAMENT_PALETTE",
|
|
221
|
+
"Palette",
|
|
222
|
+
"get_model_palette",
|
|
223
|
+
"get_palette_for_model",
|
|
224
|
+
"snap_to_model_palette",
|
|
225
|
+
"snap_to_ad5x_palette",
|
|
226
|
+
"snap_to_creator5_palette",
|
|
227
|
+
# Status model
|
|
228
|
+
"PrinterSnapshot",
|
|
229
|
+
"PrinterRunState",
|
|
230
|
+
"TemperatureReading",
|
|
231
|
+
"JobSnapshot",
|
|
232
|
+
"JobProgress",
|
|
233
|
+
"MaterialStationSnapshot",
|
|
234
|
+
"MaterialSlotSnapshot",
|
|
235
|
+
# Exceptions
|
|
236
|
+
"FlashForgeError",
|
|
237
|
+
"FlashForgeResponseError",
|
|
238
|
+
"NotSupportedError",
|
|
239
|
+
"InvalidParameterError",
|
|
240
|
+
"PrinterConnectionError",
|
|
241
|
+
# Data models
|
|
242
|
+
"FFMachineInfo",
|
|
243
|
+
"FFPrinterDetail",
|
|
244
|
+
"MachineInfoParser",
|
|
245
|
+
"FFGcodeFileEntry",
|
|
246
|
+
"FFGcodeToolData",
|
|
247
|
+
"MachineState",
|
|
248
|
+
"Temperature",
|
|
249
|
+
"GenericResponse",
|
|
250
|
+
"DetailResponse",
|
|
251
|
+
"ProductResponse",
|
|
252
|
+
"Product",
|
|
253
|
+
"FilamentArgs",
|
|
254
|
+
# AD5X models
|
|
255
|
+
"SlotInfo",
|
|
256
|
+
"MatlStationInfo",
|
|
257
|
+
"IndepMatlInfo",
|
|
258
|
+
"GCodeListResponse",
|
|
259
|
+
"ThumbnailResponse",
|
|
260
|
+
# Sliced 3MF parsing
|
|
261
|
+
"parse_3mf",
|
|
262
|
+
"PrinterFamily",
|
|
263
|
+
"ThreeMFError",
|
|
264
|
+
"ThreeMFFilament",
|
|
265
|
+
"ThreeMFFile",
|
|
266
|
+
"ThreeMFFormatError",
|
|
267
|
+
"ThreeMFMultiplePlatesError",
|
|
268
|
+
"ThreeMFNotSlicedError",
|
|
269
|
+
"ThreeMFWarning",
|
|
270
|
+
# TCP classes for low-level operations
|
|
271
|
+
"TcpClient",
|
|
272
|
+
"FlashForgeTcpClient",
|
|
273
|
+
"FlashForgeTcpClientOptions",
|
|
274
|
+
"FlashForgeA3Client",
|
|
275
|
+
"FlashForgeA4Client",
|
|
276
|
+
"PrinterInfo",
|
|
277
|
+
"TempInfo",
|
|
278
|
+
"TempData",
|
|
279
|
+
"LocationInfo",
|
|
280
|
+
"EndstopStatus",
|
|
281
|
+
"MachineStatus",
|
|
282
|
+
"MoveMode",
|
|
283
|
+
"Status",
|
|
284
|
+
"Endstop",
|
|
285
|
+
"PrintStatus",
|
|
286
|
+
"ThumbnailInfo",
|
|
287
|
+
"GCodes",
|
|
288
|
+
"GCodeController",
|
|
289
|
+
"A3GCodeController",
|
|
290
|
+
"LegacyGCodeController",
|
|
291
|
+
"A3BuildVolume",
|
|
292
|
+
"A3PrinterInfo",
|
|
293
|
+
"A3FileEntry",
|
|
294
|
+
"A3Thumbnail",
|
|
295
|
+
"A4BuildVolume",
|
|
296
|
+
"A4PrinterInfo",
|
|
297
|
+
"A4FileEntry",
|
|
298
|
+
# Discovery classes
|
|
299
|
+
"PrinterDiscovery",
|
|
300
|
+
"DiscoveredPrinter",
|
|
301
|
+
"DiscoveryOptions",
|
|
302
|
+
"DiscoveryProtocol",
|
|
303
|
+
"PrinterStatus",
|
|
304
|
+
"DiscoveryMonitor",
|
|
305
|
+
"DiscoveryError",
|
|
306
|
+
"InvalidResponseError",
|
|
307
|
+
"SocketCreationError",
|
|
308
|
+
"DiscoveryTimeoutError",
|
|
309
|
+
"FlashForgePrinter",
|
|
310
|
+
"FlashForgePrinterDiscovery",
|
|
311
|
+
# Utilities
|
|
312
|
+
"NetworkUtils",
|
|
313
|
+
"FNetCode",
|
|
314
|
+
"Filament",
|
|
315
|
+
"TempWrapper",
|
|
316
|
+
"format_scientific_notation",
|
|
317
|
+
"Endpoints",
|
|
318
|
+
"Commands",
|
|
319
|
+
# Package metadata
|
|
320
|
+
"__version__",
|
|
321
|
+
"__author__",
|
|
322
|
+
"__email__",
|
|
323
|
+
"__description__",
|
|
324
|
+
]
|
|
325
|
+
|
|
326
|
+
# Convenience imports for common patterns
|
|
327
|
+
State = MachineState
|
|
328
|
+
|
|
329
|
+
# Add version info accessible as flashforge.version
|
|
330
|
+
version = __version__
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def __getattr__(name: str) -> object:
|
|
334
|
+
"""Raise a clear error for names removed in 3.0 (see ``flashforge._removed``)."""
|
|
335
|
+
from ._removed import REMOVED_TOP_LEVEL, module_getattr
|
|
336
|
+
|
|
337
|
+
return module_getattr(__name__, REMOVED_TOP_LEVEL, name)
|
flashforge/_removed.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Clear errors for names that were removed in 3.0.
|
|
2
|
+
|
|
3
|
+
Code written for 1.x (for example an old Home Assistant integration) imports names
|
|
4
|
+
such as ``FlashForgeClient``. Without this module, Python only says
|
|
5
|
+
"cannot import name". The module ``__getattr__`` hooks in ``flashforge`` and
|
|
6
|
+
``flashforge.models`` raise :class:`RemovedInVersion3Error` instead, with the
|
|
7
|
+
replacement and the migration links.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
MIGRATION_GUIDE_URL = "https://gitlab.com/GhostTypes/ff-5mp-api-py/-/blob/main/CHANGELOG.md"
|
|
13
|
+
HASS_REPOSITORY_URL = "https://github.com/Parallel-7/ff-5mp-hass"
|
|
14
|
+
|
|
15
|
+
_CONNECT = "connect_printer()"
|
|
16
|
+
|
|
17
|
+
# name -> replacement, per module that exported it in 1.x.
|
|
18
|
+
REMOVED_TOP_LEVEL: dict[str, str] = {
|
|
19
|
+
"FlashForgeClient": _CONNECT,
|
|
20
|
+
"FiveMClient": _CONNECT,
|
|
21
|
+
"FiveMClientConnectionOptions": "ConnectOptions with connect_printer()",
|
|
22
|
+
"Control": "the methods of the backend that connect_printer() returns",
|
|
23
|
+
"JobControl": "the methods of the backend that connect_printer() returns",
|
|
24
|
+
"TempControl": "the methods of the backend that connect_printer() returns",
|
|
25
|
+
"Files": "the methods of the backend that connect_printer() returns",
|
|
26
|
+
"Info": "backend.get_machine_info() or backend.get_status()",
|
|
27
|
+
"PrinterModel": "PrinterModelId (DiscoveredPrinter.model)",
|
|
28
|
+
"AD5XUploadParams": "UploadJobParams",
|
|
29
|
+
"AD5XLocalJobParams": "LocalJobParams",
|
|
30
|
+
"AD5XSingleColorJobParams": "LocalJobParams",
|
|
31
|
+
"AD5XMaterialMapping": "MaterialMapping",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
REMOVED_MODELS: dict[str, str] = {
|
|
35
|
+
"AD5XUploadParams": "flashforge.UploadJobParams",
|
|
36
|
+
"AD5XLocalJobParams": "flashforge.LocalJobParams",
|
|
37
|
+
"AD5XSingleColorJobParams": "flashforge.LocalJobParams",
|
|
38
|
+
"AD5XMaterialMapping": "flashforge.MaterialMapping",
|
|
39
|
+
"Creator5UploadParams": "flashforge.UploadJobParams",
|
|
40
|
+
"Creator5JobParams": "flashforge.LocalJobParams",
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class RemovedInVersion3Error(ImportError):
|
|
45
|
+
"""A name that existed in flashforge-python-api 1.x was removed in 3.0."""
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def removed_name_error(module: str, name: str, replacement: str) -> RemovedInVersion3Error:
|
|
49
|
+
"""Build the error for ``from <module> import <name>``."""
|
|
50
|
+
message = (
|
|
51
|
+
f"'{name}' was removed in flashforge-python-api 3.0. Use {replacement} instead. "
|
|
52
|
+
f"Migration notes: {MIGRATION_GUIDE_URL}\n"
|
|
53
|
+
"Home Assistant users: the FlashForge integration moved. In HACS, remove the old "
|
|
54
|
+
f"GhostTypes repository, add {HASS_REPOSITORY_URL} and update to 1.6.2 or later. "
|
|
55
|
+
"To keep an older integration working, install flashforge-python-api<2.0."
|
|
56
|
+
)
|
|
57
|
+
return RemovedInVersion3Error(message, name=name)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def module_getattr(module: str, table: dict[str, str], name: str) -> object:
|
|
61
|
+
"""Shared body of the module ``__getattr__`` hooks."""
|
|
62
|
+
replacement = table.get(name)
|
|
63
|
+
if replacement is not None:
|
|
64
|
+
raise removed_name_error(module, name, replacement)
|
|
65
|
+
raise AttributeError(f"module '{module}' has no attribute '{name}'")
|
flashforge/api/__init__.py
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
"""
|
|
2
|
-
FlashForge Python API - API Package
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from .constants import Commands, Endpoints
|
|
6
|
-
from .
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"Files",
|
|
14
|
-
"Info",
|
|
15
|
-
"JobControl",
|
|
16
|
-
"TempControl",
|
|
17
|
-
"NetworkUtils",
|
|
18
|
-
]
|
|
1
|
+
"""
|
|
2
|
+
FlashForge Python API - API Package (HTTP constants and network helpers).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .constants import Commands, Endpoints
|
|
6
|
+
from .network import NetworkUtils
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"Commands",
|
|
10
|
+
"Endpoints",
|
|
11
|
+
"NetworkUtils",
|
|
12
|
+
]
|