pushraker 0.2.2__tar.gz → 0.2.4__tar.gz
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.
- {pushraker-0.2.2/src/pushraker.egg-info → pushraker-0.2.4}/PKG-INFO +1 -1
- {pushraker-0.2.2 → pushraker-0.2.4}/pyproject.toml +1 -1
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/__init__.py +1 -1
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/component.py +103 -6
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/printers/__init__.py +7 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/printers/snapmaker_u1.py +18 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/settings.py +16 -3
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/web/index.html +74 -23
- {pushraker-0.2.2 → pushraker-0.2.4/src/pushraker.egg-info}/PKG-INFO +1 -1
- {pushraker-0.2.2 → pushraker-0.2.4}/tests/test_pushraker.py +75 -1
- {pushraker-0.2.2 → pushraker-0.2.4}/tests/test_settings.py +8 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/LICENSE +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/README.md +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/setup.cfg +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/__main__.py +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/discord.py +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/email_html.py +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/images.py +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker/klipper/pushraker.cfg +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker.egg-info/SOURCES.txt +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker.egg-info/dependency_links.txt +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker.egg-info/requires.txt +0 -0
- {pushraker-0.2.2 → pushraker-0.2.4}/src/pushraker.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pushraker
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Push notifications for Klipper printers: a Moonraker component with pictures, sent through Apprise (ntfy, Pushover, Telegram, Discord, webhooks, email)
|
|
5
5
|
Author: noon92
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pushraker"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.4"
|
|
8
8
|
description = "Push notifications for Klipper printers: a Moonraker component with pictures, sent through Apprise (ntfy, Pushover, Telegram, Discord, webhooks, email)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "GPL-3.0-or-later"
|
|
@@ -102,7 +102,7 @@ REMOTE_METHOD = "pushraker"
|
|
|
102
102
|
OLD_REMOTE_METHOD = "push_notification"
|
|
103
103
|
MILESTONES = (25, 50, 75)
|
|
104
104
|
ROW_IDS = (
|
|
105
|
-
"started", "layer_started", "first_layer", "progress_25", "progress_50", "progress_75",
|
|
105
|
+
"started", "preprint_done", "layer_started", "first_layer", "progress_25", "progress_50", "progress_75",
|
|
106
106
|
"status_report",
|
|
107
107
|
"paused", "file_pause", "resumed", "object_complete", "complete", "cancelled",
|
|
108
108
|
"calibration",
|
|
@@ -115,6 +115,7 @@ ROW_IDS = (
|
|
|
115
115
|
SPOOLMAN_ROWS = ("filament_short", "filament_low", "spool_switch")
|
|
116
116
|
TITLES = {
|
|
117
117
|
"started": "▶️ {name} started",
|
|
118
|
+
"preprint_done": "▶️ {name} pre-print calibrations complete",
|
|
118
119
|
"layer_started": "🎬 {name} first layer started",
|
|
119
120
|
"first_layer": "🔍 {name} {ordinal} layer complete",
|
|
120
121
|
"progress": "⏳ {name} {pct}%",
|
|
@@ -254,7 +255,7 @@ NOTIFY_TYPES = {"complete": "success", "object_complete": "success",
|
|
|
254
255
|
FILE_CAP = 30
|
|
255
256
|
# Emails about one print go in one thread (see _email_prepare). Faults
|
|
256
257
|
# join it while printing and this long after the print ended.
|
|
257
|
-
THREAD_ROWS = ("started", "layer_started", "first_layer",
|
|
258
|
+
THREAD_ROWS = ("started", "preprint_done", "layer_started", "first_layer",
|
|
258
259
|
"progress_25", "progress_50",
|
|
259
260
|
"progress_75", "status_report", "paused", "file_pause", "resumed", "object_complete",
|
|
260
261
|
"complete", "cancelled",
|
|
@@ -268,6 +269,10 @@ PTC_FIELDS = ["extruder_map_table", "filament_spool_id", "extruders_used",
|
|
|
268
269
|
"filament_exist", "filament_vendor", "filament_type",
|
|
269
270
|
"filament_sub_type", "filament_color_rgba",
|
|
270
271
|
"filament_color_multi"]
|
|
272
|
+
# The pre-print calibrations chosen for a job (printers that have them)
|
|
273
|
+
PREPRINT_FIELDS = ["auto_bed_leveling", "flow_calibrate",
|
|
274
|
+
"flow_calib_extruders", "shaper_calibrate",
|
|
275
|
+
"extruders_used"]
|
|
271
276
|
# The printer refills only from a toolhead with the same nozzle
|
|
272
277
|
# (extruders: printers.py)
|
|
273
278
|
NOZZLE_FIELDS = ["nozzle_diameter", "nozzle_volume_type"]
|
|
@@ -290,7 +295,8 @@ SEND_GAP = {"ntfy": 2.} # seconds before each retry of a failed send
|
|
|
290
295
|
# notification an hour late is noise. Faults and complete never expire.
|
|
291
296
|
URGENT_ROWS = ("error", "warning", "shutdown", "power_loss",
|
|
292
297
|
"chamber_fault")
|
|
293
|
-
EXPIRING_ROWS = ("started", "
|
|
298
|
+
EXPIRING_ROWS = ("started", "preprint_done", "layer_started", "first_layer",
|
|
299
|
+
"progress_25",
|
|
294
300
|
"progress_50", "progress_75", "object_complete",
|
|
295
301
|
"chamber_waiting", "chamber_reached", "filament_change")
|
|
296
302
|
STATUS_EXPIRY = 300.
|
|
@@ -887,6 +893,12 @@ class PushNotifications:
|
|
|
887
893
|
self._job_done_sent = False
|
|
888
894
|
self._first_layer_sent = False
|
|
889
895
|
self._layer_started_sent = False
|
|
896
|
+
# Pre-print calibrations of this job: their names (for the started
|
|
897
|
+
# notification), the ones still to run, the one running now
|
|
898
|
+
self._pp_names: List[str] = []
|
|
899
|
+
self._pp_pending: set = set()
|
|
900
|
+
self._pp_running: Optional[Tuple[str, Optional[int]]] = None
|
|
901
|
+
self._pp_sent = True
|
|
890
902
|
self._milestones_sent: Set[int] = set()
|
|
891
903
|
# Print time (which stops while paused) the next status report is
|
|
892
904
|
# due at; None until the job's first status update sets it
|
|
@@ -1010,7 +1022,8 @@ class PushNotifications:
|
|
|
1010
1022
|
error_index_url=self.error_index_url,
|
|
1011
1023
|
name=self.store.default_name if self.store
|
|
1012
1024
|
else self.name,
|
|
1013
|
-
rows_unavailable=self.printer.rows_unavailable
|
|
1025
|
+
rows_unavailable=self.printer.rows_unavailable,
|
|
1026
|
+
preprint=bool(self.printer.preprint_calibrations))
|
|
1014
1027
|
|
|
1015
1028
|
async def _reload(self, why: str) -> None:
|
|
1016
1029
|
"""Read pushraker.conf and apply it. Settings that don't pass
|
|
@@ -1959,6 +1972,7 @@ class PushNotifications:
|
|
|
1959
1972
|
float(ps.get("print_duration") or 0.) > RECOVERY_MIN_TIME
|
|
1960
1973
|
or progress >= RECOVERY_SURE_PROGRESS)
|
|
1961
1974
|
self._thread_start(filename, recovered)
|
|
1975
|
+
self._preprint_seed(recovered)
|
|
1962
1976
|
if recovered:
|
|
1963
1977
|
# Snapmaker resumes a power-loss print as a new job
|
|
1964
1978
|
self._spawn(self._send(
|
|
@@ -1970,7 +1984,8 @@ class PushNotifications:
|
|
|
1970
1984
|
self._lines(shown(filename),
|
|
1971
1985
|
self._slicer_estimate(filename),
|
|
1972
1986
|
self._queue_line(filename, starting=True),
|
|
1973
|
-
self._pauses_line()
|
|
1987
|
+
self._pauses_line(),
|
|
1988
|
+
self._preprint_line()),
|
|
1974
1989
|
filename=filename))
|
|
1975
1990
|
# After the started notification has taken its place in the
|
|
1976
1991
|
# queues, so filament warnings always arrive after it
|
|
@@ -2047,7 +2062,9 @@ class PushNotifications:
|
|
|
2047
2062
|
self._job_done_sent = False
|
|
2048
2063
|
if query:
|
|
2049
2064
|
state = await self._query(
|
|
2050
|
-
{"print_stats": ["info"], "virtual_sdcard": ["file_position"]
|
|
2065
|
+
{"print_stats": ["info"], "virtual_sdcard": ["file_position"],
|
|
2066
|
+
**({"print_task_config": PREPRINT_FIELDS}
|
|
2067
|
+
if self.printer.preprint_calibrations else {})})
|
|
2051
2068
|
for obj in self._status:
|
|
2052
2069
|
self._status[obj].update(state.get(obj) or {})
|
|
2053
2070
|
self._gcode_bytes = self._get_gcode_bytes(filename)
|
|
@@ -2679,6 +2696,7 @@ class PushNotifications:
|
|
|
2679
2696
|
self._idle_was = idle
|
|
2680
2697
|
if "machine_state_manager" in data:
|
|
2681
2698
|
self._track_calibration()
|
|
2699
|
+
self._track_preprint()
|
|
2682
2700
|
if "filament_exist" in (data.get("print_task_config") or {}):
|
|
2683
2701
|
self._track_filament_change()
|
|
2684
2702
|
if ACE_OBJECT in data:
|
|
@@ -2710,6 +2728,12 @@ class PushNotifications:
|
|
|
2710
2728
|
self._by_object = False
|
|
2711
2729
|
logging.info("[pushraker] no object markers in %s: "
|
|
2712
2730
|
"reported as one job", shown(filename))
|
|
2731
|
+
if not self._pp_sent:
|
|
2732
|
+
# Layer 1 began: the start routine is over, even if a chosen
|
|
2733
|
+
# calibration was skipped (a toolhead already calibrated)
|
|
2734
|
+
layer = (ps.get("info") or {}).get("current_layer")
|
|
2735
|
+
if layer is not None and int(layer) >= 1:
|
|
2736
|
+
self._preprint_done(filename)
|
|
2713
2737
|
if "layer_started" in self.rows and not self._layer_started_sent:
|
|
2714
2738
|
# Layer 1 begins once the start routine (homing, bed mesh,
|
|
2715
2739
|
# flow calibration) is over: time to watch the first layer
|
|
@@ -2843,6 +2867,79 @@ class PushNotifications:
|
|
|
2843
2867
|
for p in out))
|
|
2844
2868
|
return out
|
|
2845
2869
|
|
|
2870
|
+
# ---- pre-print calibrations ----------------------------------------
|
|
2871
|
+
|
|
2872
|
+
def _preprint_seed(self, recovered: bool) -> None:
|
|
2873
|
+
"""At the job's start: which pre-print calibrations were chosen
|
|
2874
|
+
(print_task_config), and so which runs to wait for."""
|
|
2875
|
+
self._pp_names, self._pp_pending = [], set()
|
|
2876
|
+
self._pp_running, self._pp_sent = None, True
|
|
2877
|
+
cal = self.printer.preprint_calibrations
|
|
2878
|
+
if not cal or recovered:
|
|
2879
|
+
return
|
|
2880
|
+
ptc = self._status["print_task_config"]
|
|
2881
|
+
used = list(ptc.get("extruders_used") or [])
|
|
2882
|
+
which = list(ptc.get("flow_calib_extruders") or [])
|
|
2883
|
+
for flag, name in cal.items():
|
|
2884
|
+
if not ptc.get(flag):
|
|
2885
|
+
continue
|
|
2886
|
+
self._pp_names.append(name)
|
|
2887
|
+
per_tool = sorted({i for c, (f, i) in
|
|
2888
|
+
self.printer.preprint_codes.items()
|
|
2889
|
+
if f == flag and i is not None})
|
|
2890
|
+
if not per_tool:
|
|
2891
|
+
self._pp_pending.add((flag, None))
|
|
2892
|
+
continue
|
|
2893
|
+
for i in per_tool:
|
|
2894
|
+
if (i >= len(which) or which[i]) and \
|
|
2895
|
+
(i >= len(used) or used[i]):
|
|
2896
|
+
self._pp_pending.add((flag, i))
|
|
2897
|
+
self._pp_sent = not self._pp_names
|
|
2898
|
+
|
|
2899
|
+
def _preprint_line(self) -> str:
|
|
2900
|
+
if not self._pp_names:
|
|
2901
|
+
return ""
|
|
2902
|
+
# A blank line before it unless the pauses line has one
|
|
2903
|
+
return ("" if self._job_pauses else "\n") + \
|
|
2904
|
+
"Pre-print calibrations selected: " + \
|
|
2905
|
+
", ".join(self._pp_names) + "."
|
|
2906
|
+
|
|
2907
|
+
def _track_preprint(self) -> None:
|
|
2908
|
+
"""During the job's start routine: each chosen calibration's
|
|
2909
|
+
action_code while it runs, back to idle when done; when none is
|
|
2910
|
+
left, they are complete (also when layer 1 begins first)."""
|
|
2911
|
+
if self._pp_sent or not self._job_active:
|
|
2912
|
+
return
|
|
2913
|
+
try:
|
|
2914
|
+
action = int(self._status["machine_state_manager"]
|
|
2915
|
+
.get("action_code") or 0)
|
|
2916
|
+
except (TypeError, ValueError):
|
|
2917
|
+
return
|
|
2918
|
+
step = self.printer.preprint_codes.get(action)
|
|
2919
|
+
if step is not None:
|
|
2920
|
+
self._pp_running = step
|
|
2921
|
+
return
|
|
2922
|
+
if self._pp_running is None or action != 0:
|
|
2923
|
+
return
|
|
2924
|
+
self._pp_pending.discard(self._pp_running)
|
|
2925
|
+
self._pp_running = None
|
|
2926
|
+
if not self._pp_pending:
|
|
2927
|
+
self._preprint_done(self._job_filename)
|
|
2928
|
+
|
|
2929
|
+
def _preprint_done(self, filename: str) -> None:
|
|
2930
|
+
self._pp_sent = True
|
|
2931
|
+
if cfgmod.PREPRINT_ROW not in self.rows:
|
|
2932
|
+
return
|
|
2933
|
+
names = self._pp_names
|
|
2934
|
+
done = names[0] if len(names) == 1 else \
|
|
2935
|
+
", ".join(names[:-1]) + " and " + names[-1]
|
|
2936
|
+
self._spawn(self._send(
|
|
2937
|
+
cfgmod.PREPRINT_ROW, self._title("preprint_done"),
|
|
2938
|
+
self._lines(shown(filename),
|
|
2939
|
+
f"{done} done. Starting the print job.",
|
|
2940
|
+
self._time_left()),
|
|
2941
|
+
filename=filename))
|
|
2942
|
+
|
|
2846
2943
|
def _pauses_line(self) -> str:
|
|
2847
2944
|
"""For the started notification: how many pauses the file has."""
|
|
2848
2945
|
ps = self._job_pauses
|
|
@@ -50,6 +50,13 @@ class Printer:
|
|
|
50
50
|
# The printer's own toolhead map and refill (print_task_config): with
|
|
51
51
|
# it, runouts can be refilled from another toolhead
|
|
52
52
|
toolhead_map = False
|
|
53
|
+
# Pre-print calibrations a print job can be started with (chosen on
|
|
54
|
+
# the printer when the job starts): the flag in print_task_config ->
|
|
55
|
+
# its name; and the action_code values (machine_state_manager) while
|
|
56
|
+
# each runs, -> (the flag, the toolhead index for per-toolhead ones,
|
|
57
|
+
# else None). Empty: the printer has none (no line, no checkbox)
|
|
58
|
+
preprint_calibrations: Dict[str, str] = {}
|
|
59
|
+
preprint_codes: Dict[int, Tuple[str, Optional[int]]] = {}
|
|
53
60
|
# The print-end snapshot lift keeps Z at or below this; 0 means 5 mm
|
|
54
61
|
# under the printer's axis maximum (the macro file reads it)
|
|
55
62
|
lift_ceiling = 0
|
|
@@ -36,6 +36,24 @@ class SnapmakerU1(Printer):
|
|
|
36
36
|
"/home/lava/printer_data/config/snapmaker/pl_print_file_env.json",
|
|
37
37
|
)
|
|
38
38
|
toolhead_map = True
|
|
39
|
+
# Chosen on the screen when a print job starts (print_task_config.py);
|
|
40
|
+
# while each runs, machine_state_manager's action_code is BED_PREHEATING
|
|
41
|
+
# (257), BED_PRESCANNING (258), BED_LEVELING (256),
|
|
42
|
+
# EXTRUDER<n>_FLOW_CALIBRATING (320 + toolhead) or SHAPER_CALIBRATING
|
|
43
|
+
# (384), back to IDLE (0) after each (seen on a U1: 257, 258, 256, 0;
|
|
44
|
+
# 323, 0)
|
|
45
|
+
preprint_calibrations = {
|
|
46
|
+
"auto_bed_leveling": "Bed levelling",
|
|
47
|
+
"flow_calibrate": "Extrusion flow calibration (pressure advance)",
|
|
48
|
+
"shaper_calibrate": "Input shaper calibration",
|
|
49
|
+
}
|
|
50
|
+
preprint_codes = {
|
|
51
|
+
256: ("auto_bed_leveling", None), 257: ("auto_bed_leveling", None),
|
|
52
|
+
258: ("auto_bed_leveling", None),
|
|
53
|
+
320: ("flow_calibrate", 0), 321: ("flow_calibrate", 1),
|
|
54
|
+
322: ("flow_calibrate", 2), 323: ("flow_calibrate", 3),
|
|
55
|
+
384: ("shaper_calibrate", None),
|
|
56
|
+
}
|
|
39
57
|
rows_unavailable: Sequence[str] = ()
|
|
40
58
|
# The stock PRINT_END / CANCEL_PRINT raise Z by 5 mm below 265 mm; the
|
|
41
59
|
# lift stays inside that
|
|
@@ -118,6 +118,9 @@ OBJECT_ROW = "object_complete"
|
|
|
118
118
|
# A pause the print job's file asks for is sent with the Paused row's
|
|
119
119
|
# destinations at the highest priority: the file wants something from you
|
|
120
120
|
FILE_PAUSE_ROW = "file_pause"
|
|
121
|
+
# Pre-print calibrations done (printers that have them): sent with the
|
|
122
|
+
# Print started row's settings, when its checkbox is on
|
|
123
|
+
PREPRINT_ROW = "preprint_done"
|
|
121
124
|
ERROR_ROWS = ("error", "warning", "shutdown")
|
|
122
125
|
# Rows that read Spoolman (the first two need it; the switch works without)
|
|
123
126
|
SPOOLMAN_ROWS = ("filament_short", "filament_low", "spool_switch")
|
|
@@ -168,7 +171,7 @@ SECRET_FIELDS = ("secret", "email_password", "webhook_url")
|
|
|
168
171
|
INT_FIELDS = ("layers_complete", "email_port", "filament_low_percent",
|
|
169
172
|
"filament_low_grams", "driver_temp", "report_interval")
|
|
170
173
|
BOOL_FIELDS = ("enabled", "push_enabled", "email_enabled", "webhook_enabled",
|
|
171
|
-
"filament_unknown")
|
|
174
|
+
"filament_unknown", "preprint_done")
|
|
172
175
|
# Settings the form fills in for common providers
|
|
173
176
|
EMAIL_PRESETS = {
|
|
174
177
|
"gmail": {"label": "Gmail", "host": "smtp.gmail.com", "port": 587,
|
|
@@ -201,14 +204,18 @@ class Env:
|
|
|
201
204
|
name the printer's default name
|
|
202
205
|
rows_unavailable rows the printer can't produce (off by default and
|
|
203
206
|
left off the page unless turned on in pushraker.conf)
|
|
207
|
+
preprint the printer has pre-print calibrations (the Print
|
|
208
|
+
started row's checkbox)
|
|
204
209
|
"""
|
|
205
210
|
|
|
206
211
|
def __init__(self, cameras: Optional[Dict[str, Dict[str, str]]] = None,
|
|
207
212
|
spoolman_url: str = "", local_ip: str = "",
|
|
208
213
|
tailscale: Tuple[str, str] = ("", ""),
|
|
209
214
|
error_index_url: str = "", name: str = "Printer",
|
|
210
|
-
rows_unavailable: Sequence[str] = ()
|
|
215
|
+
rows_unavailable: Sequence[str] = (),
|
|
216
|
+
preprint: bool = False) -> None:
|
|
211
217
|
self.cameras = cameras or {}
|
|
218
|
+
self.preprint = preprint
|
|
212
219
|
self.rows_unavailable = set(rows_unavailable)
|
|
213
220
|
self.spoolman_url = spoolman_url.rstrip("/")
|
|
214
221
|
self.local_ip = local_ip
|
|
@@ -265,6 +272,9 @@ def _defaults(name: str) -> Dict[str, Any]:
|
|
|
265
272
|
"filament_low_percent": 10,
|
|
266
273
|
"filament_low_grams": 50,
|
|
267
274
|
"filament_unknown": True,
|
|
275
|
+
# Under Print started: also notify when the pre-print calibrations
|
|
276
|
+
# chosen for the job are done
|
|
277
|
+
"preprint_done": True,
|
|
268
278
|
"driver_temp": 105, # °C, X or Y stepper driver (row: driver_hot)
|
|
269
279
|
"report_interval": 30, # minutes of print time between status reports
|
|
270
280
|
"email_enabled": False,
|
|
@@ -1120,7 +1130,9 @@ def render_options(s: Dict[str, Any], env: Env) -> Dict[str, str]:
|
|
|
1120
1130
|
# The object-complete notification follows the Print complete row
|
|
1121
1131
|
for name in ([rid, OBJECT_ROW] if rid == "complete"
|
|
1122
1132
|
and s["complete_objects"] == "each" else
|
|
1123
|
-
[rid, FILE_PAUSE_ROW] if rid == "paused" else
|
|
1133
|
+
[rid, FILE_PAUSE_ROW] if rid == "paused" else
|
|
1134
|
+
[rid, PREPRINT_ROW] if rid == "started"
|
|
1135
|
+
and s["preprint_done"] and env.preprint else [rid]):
|
|
1124
1136
|
if rid in push:
|
|
1125
1137
|
url = row_url(s, rid, "max" if name == FILE_PAUSE_ROW
|
|
1126
1138
|
else s["rows"][rid]["priority"], env)
|
|
@@ -1257,6 +1269,7 @@ def public_view(s: Dict[str, Any], env: Env, busy: bool,
|
|
|
1257
1269
|
for r in ROWS],
|
|
1258
1270
|
"email_presets": EMAIL_PRESETS,
|
|
1259
1271
|
"spoolman": bool(env.spoolman_url),
|
|
1272
|
+
"preprint": env.preprint,
|
|
1260
1273
|
"priorities": PRIORITIES,
|
|
1261
1274
|
"providers": PROVIDERS,
|
|
1262
1275
|
"cameras": {name: {"snapshot": bool(c.get("snapshot")),
|
|
@@ -35,14 +35,26 @@
|
|
|
35
35
|
(on a phone: one line, those two at the left, it at the right) */
|
|
36
36
|
.btn-save { background: #2e7d32; color: #fff; font-size: 15px; min-height: 42px; padding: 10px 24px; margin-left: 40px; }
|
|
37
37
|
@media (max-width: 600px) {
|
|
38
|
-
.btn-save {
|
|
38
|
+
.btn-save { padding: 10px 16px; white-space: nowrap; }
|
|
39
|
+
.pr-save-wrap { margin-left: auto; }
|
|
39
40
|
.pr-actions .btn { white-space: nowrap; }
|
|
40
41
|
.pr-status { flex-basis: 100%; }
|
|
41
42
|
}
|
|
42
43
|
.btn-save:hover:not(:disabled) { background: #388e3c; }
|
|
43
|
-
.pr-
|
|
44
|
+
.pr-save-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; margin-left: 40px; }
|
|
45
|
+
.pr-save-wrap .btn-save { margin-left: 0; }
|
|
46
|
+
.pr-safe { display: none; font-size: 11px; color: var(--success); white-space: nowrap; }
|
|
47
|
+
.pr-safe.on { display: block; }
|
|
48
|
+
/* Save and Send Test progress: a popup like Firmware Config's */
|
|
49
|
+
.pr-run .pr-modal-box { max-width: 720px; border-radius: 12px; padding: 24px; max-height: 80vh; display: flex; flex-direction: column; }
|
|
50
|
+
.pr-run h3 { font-size: 18px; margin-bottom: 16px; }
|
|
51
|
+
.pr-run-msg { color: var(--text); margin-bottom: 16px; font-size: 14px; }
|
|
52
|
+
.pr-run-msg.ok { color: var(--success); }
|
|
53
|
+
.pr-run-msg.err { color: var(--error); }
|
|
54
|
+
.pr-console { background: #0d0d0d; color: #ddd; font-family: monospace; font-size: 12px; padding: 12px; border-radius: 6px; white-space: pre-wrap; word-wrap: break-word; height: 300px; max-height: 50vh; overflow-y: auto; margin-bottom: 16px; }
|
|
44
55
|
.pr-console .err { color: var(--error); font-weight: 600; }
|
|
45
56
|
.pr-console .ok { color: var(--success); }
|
|
57
|
+
.pr-run .btn { padding: 10px 20px; font-size: 14px; }
|
|
46
58
|
.pr-error { color: var(--error); font-size: 13px; margin: 8px 0; font-weight: 500; scroll-margin-bottom: 90px; }
|
|
47
59
|
.pr-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 10; padding: 20px; }
|
|
48
60
|
.pr-modal.open { display: flex; }
|
|
@@ -50,10 +62,9 @@
|
|
|
50
62
|
.pr-modal-box h3 { color: #fff; margin-bottom: 12px; font-size: 16px; }
|
|
51
63
|
.pr-modal-box p { white-space: pre-wrap; margin-bottom: 20px; font-size: 14px; line-height: 1.5; }
|
|
52
64
|
.pr-modal-box .pr-buttons { display: flex; gap: 10px; justify-content: flex-end; }
|
|
53
|
-
.pr-discard
|
|
54
|
-
.pr-discard
|
|
55
|
-
.pr-discard
|
|
56
|
-
.pr-discard .btn { font-size: 15px; min-height: 42px; padding: 10px 18px; }
|
|
65
|
+
.pr-discard h3 { font-size: 18px; }
|
|
66
|
+
.pr-discard p { font-size: 15px; }
|
|
67
|
+
.pr-discard .btn { font-size: 14px; min-height: 38px; padding: 8px 16px; }
|
|
57
68
|
.btn-keep { background: #2e7d32; color: #fff; }
|
|
58
69
|
.btn-keep:hover { background: #388e3c; }
|
|
59
70
|
.btn-discard { background: #c62828; color: #fff; }
|
|
@@ -87,7 +98,7 @@
|
|
|
87
98
|
.nt-name { color: #fff; }
|
|
88
99
|
.nt-icon { display: inline-block; width: 24px; }
|
|
89
100
|
.nt-table select.nt-input.nt-layer { width: auto; padding: 4px 6px; display: inline-block; font-family: inherit; }
|
|
90
|
-
.nt-sub { display: block; margin-top: 4px; font-size: 12px; color: #8a8f98; white-space: nowrap; }
|
|
101
|
+
.nt-sub { display: block; margin-top: 4px; padding-left: 26px; font-size: 12px; color: #8a8f98; white-space: nowrap; }
|
|
91
102
|
.nt-sub select.nt-input.nt-layer { font-size: 12px; padding: 2px 4px; max-width: 140px; }
|
|
92
103
|
.nt-sub input.nt-input.nt-deg { width: 56px; font-size: 12px; padding: 2px 4px; display: inline-block; }
|
|
93
104
|
.nt-foot { font-size: 12px; color: #8a8f98; margin: 0 0 16px; }
|
|
@@ -400,19 +411,32 @@
|
|
|
400
411
|
</div>
|
|
401
412
|
</div>
|
|
402
413
|
|
|
403
|
-
<div class="pr-console" id="pr-console"></div>
|
|
404
414
|
<div class="pr-error" id="pr-error" style="display:none"></div>
|
|
405
415
|
<div class="pr-actions">
|
|
406
416
|
<button type="button" class="btn btn-secondary" id="pr-close">Cancel</button>
|
|
407
417
|
<button type="button" class="btn btn-secondary" id="pr-test">Send Test</button>
|
|
408
|
-
<
|
|
418
|
+
<span class="pr-save-wrap">
|
|
419
|
+
<button type="button" class="btn btn-save" id="pr-save">Save & Apply</button>
|
|
420
|
+
<span class="pr-safe" id="pr-safe">✓ Safe to save while printing</span>
|
|
421
|
+
</span>
|
|
409
422
|
<span class="pr-status" id="pr-status"></span>
|
|
410
423
|
</div>
|
|
411
424
|
|
|
425
|
+
<div class="pr-modal pr-run" id="pr-run" role="dialog" aria-labelledby="pr-run-title">
|
|
426
|
+
<div class="pr-modal-box">
|
|
427
|
+
<h3 id="pr-run-title"></h3>
|
|
428
|
+
<div class="pr-run-msg" id="pr-run-msg"></div>
|
|
429
|
+
<div class="pr-console" id="pr-console"></div>
|
|
430
|
+
<div class="pr-buttons">
|
|
431
|
+
<button type="button" class="btn btn-secondary" id="pr-run-close" disabled>Close</button>
|
|
432
|
+
</div>
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
435
|
+
|
|
412
436
|
<div class="pr-modal pr-discard" id="pr-discard" role="alertdialog" aria-labelledby="pr-discard-title">
|
|
413
437
|
<div class="pr-modal-box">
|
|
414
|
-
<h3 id="pr-discard-title"
|
|
415
|
-
<p>
|
|
438
|
+
<h3 id="pr-discard-title">Leave without saving?</h3>
|
|
439
|
+
<p>The changes you made on this page will not be kept.</p>
|
|
416
440
|
<div class="pr-buttons">
|
|
417
441
|
<button type="button" class="btn btn-discard" id="pr-discard-yes" disabled>Discard changes</button>
|
|
418
442
|
<button type="button" class="btn btn-keep" id="pr-discard-no">Keep editing</button>
|
|
@@ -539,6 +563,8 @@
|
|
|
539
563
|
: '';
|
|
540
564
|
const calib = meta.id === 'calibration'
|
|
541
565
|
? '<span class="nt-sub">Notifies when complete, failed or requires user intervention</span>'
|
|
566
|
+
: meta.id === 'started' && state.meta.preprint
|
|
567
|
+
? `<span class="nt-sub"><label><input type="checkbox" id="nt-preprint"${state.preprint_done ? ' checked' : ''}> Notify when pre-print calibrations finish</label></span>`
|
|
542
568
|
: meta.id === 'filament_change'
|
|
543
569
|
? `<span class="nt-sub"><label style="margin-right:12px"><input type="checkbox" id="nt-fc-loaded"${state.filament_change_events.includes('loaded') ? ' checked' : ''}> Loaded</label><label><input type="checkbox" id="nt-fc-unloaded"${state.filament_change_events.includes('unloaded') ? ' checked' : ''}> Unloaded</label></span>`
|
|
544
570
|
: meta.id === 'chamber_waiting'
|
|
@@ -885,6 +911,8 @@
|
|
|
885
911
|
};
|
|
886
912
|
});
|
|
887
913
|
el('pr-status').textContent = data.meta.summary || '';
|
|
914
|
+
// During a print job: every setting applies live, nothing restarts
|
|
915
|
+
el('pr-safe').classList.toggle('on', !!data.meta.busy);
|
|
888
916
|
el('pr-loading').classList.add('pr-hidden');
|
|
889
917
|
el('nt-root').classList.remove('pr-hidden');
|
|
890
918
|
saved = JSON.stringify(collect(false));
|
|
@@ -968,6 +996,7 @@
|
|
|
968
996
|
filament_low_percent: parseInt(el('nt-fl-percent').value, 10) || 0,
|
|
969
997
|
filament_low_grams: parseInt(el('nt-fl-grams').value, 10) || 0,
|
|
970
998
|
filament_unknown: el('nt-fl-unknown').checked,
|
|
999
|
+
preprint_done: el('nt-preprint') ? el('nt-preprint').checked : !!state.preprint_done,
|
|
971
1000
|
email_enabled: emailEnabled,
|
|
972
1001
|
email_host: el('nt-email-host').value.trim(),
|
|
973
1002
|
email_port: parseInt(el('nt-email-port').value, 10) || 0,
|
|
@@ -993,17 +1022,33 @@
|
|
|
993
1022
|
if (msg) el('pr-error').scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
994
1023
|
}
|
|
995
1024
|
|
|
996
|
-
|
|
1025
|
+
// Save and Send Test run in a popup (as Firmware Config's actions
|
|
1026
|
+
// do): a message, the log, and Close once it's finished
|
|
1027
|
+
function runStart(title, message) {
|
|
1028
|
+
el('pr-run-title').textContent = title;
|
|
1029
|
+
runMessage(message, '');
|
|
1030
|
+
el('pr-console').innerHTML = '';
|
|
1031
|
+
el('pr-run-close').disabled = true;
|
|
1032
|
+
el('pr-run').classList.add('open');
|
|
1033
|
+
}
|
|
1034
|
+
function runMessage(html, kind) {
|
|
1035
|
+
el('pr-run-msg').innerHTML = html;
|
|
1036
|
+
el('pr-run-msg').className = 'pr-run-msg' + (kind ? ' ' + kind : '');
|
|
1037
|
+
}
|
|
1038
|
+
function runEnd(html, ok) {
|
|
1039
|
+
runMessage(html, ok ? 'ok' : 'err');
|
|
1040
|
+
el('pr-run-close').disabled = false;
|
|
1041
|
+
el('pr-run-close').focus();
|
|
1042
|
+
}
|
|
1043
|
+
el('pr-run-close').onclick = () => el('pr-run').classList.remove('open');
|
|
1044
|
+
|
|
1045
|
+
function showConsole(lines) {
|
|
997
1046
|
const box = el('pr-console');
|
|
998
1047
|
box.innerHTML = lines.map(l => {
|
|
999
1048
|
const c = l.startsWith('!! ') ? 'err' : (/^(Sent to|Test notification sent|Settings saved)/.test(l) ? 'ok' : '');
|
|
1000
1049
|
return `<div class="${c}">${esc(l.replace(/^!! /, ''))}</div>`;
|
|
1001
1050
|
}).join('');
|
|
1002
|
-
box.style.display = lines.length ? 'block' : 'none';
|
|
1003
1051
|
box.scrollTop = box.scrollHeight;
|
|
1004
|
-
// The console is at the end of the page: bring it into view, or
|
|
1005
|
-
// on a long page it is never seen
|
|
1006
|
-
if (lines.length) box.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
1007
1052
|
}
|
|
1008
1053
|
|
|
1009
1054
|
function busy(on, what) {
|
|
@@ -1017,15 +1062,18 @@
|
|
|
1017
1062
|
let payload;
|
|
1018
1063
|
try { payload = collect(true); } catch (e) { showError(e.message); return; }
|
|
1019
1064
|
busy(true, 'Saving…');
|
|
1065
|
+
runStart('Save & Apply', 'Saving and applying settings…');
|
|
1020
1066
|
try {
|
|
1021
1067
|
const data = await api('/server/pushraker/config', 'POST', payload);
|
|
1022
1068
|
const notes = (data.notes || []).slice();
|
|
1023
1069
|
render(data);
|
|
1024
|
-
showConsole(['Settings saved and applied. Nothing restarts: they are in effect now, during a print job too.'].concat(notes)
|
|
1070
|
+
showConsole(['Settings saved and applied. Nothing restarts: they are in effect now, during a print job too.'].concat(notes));
|
|
1025
1071
|
el('pr-status').textContent = 'Saved and applied';
|
|
1072
|
+
runEnd('Done', true);
|
|
1026
1073
|
} catch (e) {
|
|
1027
|
-
|
|
1074
|
+
showConsole(['!! ' + e.message]);
|
|
1028
1075
|
el('pr-status').textContent = '';
|
|
1076
|
+
runEnd('Not saved', false);
|
|
1029
1077
|
} finally {
|
|
1030
1078
|
busy(false);
|
|
1031
1079
|
}
|
|
@@ -1036,15 +1084,18 @@
|
|
|
1036
1084
|
let payload;
|
|
1037
1085
|
try { payload = collect(true); } catch (e) { showError(e.message); return; }
|
|
1038
1086
|
busy(true, 'Sending a test notification…');
|
|
1039
|
-
|
|
1087
|
+
runStart('Send Test', 'Sending a test notification (this can take up to a minute per destination)…');
|
|
1088
|
+
const failed = 'Test failed.' + guideLink('troubleshooting', 'Troubleshooting');
|
|
1040
1089
|
try {
|
|
1041
1090
|
const data = await api('/server/pushraker/test', 'POST', payload);
|
|
1042
|
-
showConsole(data.lines || []
|
|
1091
|
+
showConsole(data.lines || []);
|
|
1043
1092
|
if (data.ok) el('pr-status').textContent = 'Test sent';
|
|
1044
|
-
else el('pr-status').innerHTML =
|
|
1093
|
+
else el('pr-status').innerHTML = failed;
|
|
1094
|
+
runEnd(data.ok ? 'Test sent' : failed, data.ok);
|
|
1045
1095
|
} catch (e) {
|
|
1046
|
-
showConsole(['!! ' + e.message]
|
|
1047
|
-
el('pr-status').innerHTML =
|
|
1096
|
+
showConsole(['!! ' + e.message]);
|
|
1097
|
+
el('pr-status').innerHTML = failed;
|
|
1098
|
+
runEnd(failed, false);
|
|
1048
1099
|
} finally {
|
|
1049
1100
|
busy(false);
|
|
1050
1101
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pushraker
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Push notifications for Klipper printers: a Moonraker component with pictures, sent through Apprise (ntfy, Pushover, Telegram, Discord, webhooks, email)
|
|
5
5
|
Author: noon92
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -2243,6 +2243,80 @@ async def test_config_lines():
|
|
|
2243
2243
|
SECRETS.clear()
|
|
2244
2244
|
|
|
2245
2245
|
|
|
2246
|
+
async def test_preprint():
|
|
2247
|
+
print("Pre-print calibrations: listed at the start, then complete")
|
|
2248
|
+
reset_world()
|
|
2249
|
+
log = []
|
|
2250
|
+
ntfy = FakeService(log, "ntfy")
|
|
2251
|
+
server, c = make({}, {"started": [("ntfy", ntfy, False)],
|
|
2252
|
+
"preprint_done": [("ntfy", ntfy, False)]})
|
|
2253
|
+
STATE["print_task_config"] = dict(
|
|
2254
|
+
auto_bed_leveling=True, flow_calibrate=True, shaper_calibrate=False,
|
|
2255
|
+
flow_calib_extruders=[True] * 4,
|
|
2256
|
+
extruders_used=[False, False, False, True])
|
|
2257
|
+
|
|
2258
|
+
async def msm(action):
|
|
2259
|
+
await c._on_status_update(
|
|
2260
|
+
{"machine_state_manager": {"main_state": 1,
|
|
2261
|
+
"action_code": action}}, 0)
|
|
2262
|
+
await start_job(server)
|
|
2263
|
+
await asyncio.sleep(0.3)
|
|
2264
|
+
check("Print started lists the chosen calibrations",
|
|
2265
|
+
len(log) == 1 and "Pre-print calibrations selected: Bed levelling, "
|
|
2266
|
+
"Extrusion flow calibration (pressure advance)." in log[0]["body"],
|
|
2267
|
+
[e["body"] for e in log])
|
|
2268
|
+
log.clear()
|
|
2269
|
+
for a in (136, 0, 2, 0, 257, 258, 256, 0): # as logged on a U1
|
|
2270
|
+
await msm(a)
|
|
2271
|
+
await asyncio.sleep(0.3)
|
|
2272
|
+
check("not complete while a chosen one (T4's flow) is still to run",
|
|
2273
|
+
log == [], [e["title"] for e in log])
|
|
2274
|
+
await msm(323)
|
|
2275
|
+
await msm(0)
|
|
2276
|
+
await asyncio.sleep(0.3)
|
|
2277
|
+
check("complete once the last one is back to idle",
|
|
2278
|
+
[e["title"] for e in log] ==
|
|
2279
|
+
["▶️ U1 pre-print calibrations complete"]
|
|
2280
|
+
and "Bed levelling and Extrusion flow calibration (pressure advance) done"
|
|
2281
|
+
in log[0]["body"], [(e["title"], e["body"]) for e in log])
|
|
2282
|
+
log.clear()
|
|
2283
|
+
await c._on_status_update({"print_stats": {"info": {"current_layer": 1}}}, 0)
|
|
2284
|
+
await asyncio.sleep(0.2)
|
|
2285
|
+
check("sent once", log == [], [e["title"] for e in log])
|
|
2286
|
+
# A chosen flow calibration that doesn't run (that toolhead already
|
|
2287
|
+
# calibrated): layer 1 ends the wait
|
|
2288
|
+
STATE["print_task_config"].update(auto_bed_leveling=False)
|
|
2289
|
+
STATE["print_stats"] = ps("complete")
|
|
2290
|
+
await server.handlers["job_state:state_changed"](
|
|
2291
|
+
JobEvent.COMPLETE, {}, STATE["print_stats"])
|
|
2292
|
+
await asyncio.sleep(0.2)
|
|
2293
|
+
log.clear()
|
|
2294
|
+
await start_job(server)
|
|
2295
|
+
await asyncio.sleep(0.2)
|
|
2296
|
+
log.clear()
|
|
2297
|
+
STATE["print_stats"]["info"] = {"current_layer": 1}
|
|
2298
|
+
await c._on_status_update({"print_stats": {"info": {"current_layer": 1}}}, 0)
|
|
2299
|
+
await asyncio.sleep(0.3)
|
|
2300
|
+
check("a skipped one: complete when layer 1 begins",
|
|
2301
|
+
[e["title"] for e in log] == ["▶️ U1 pre-print calibrations complete"],
|
|
2302
|
+
[e["title"] for e in log])
|
|
2303
|
+
log.clear()
|
|
2304
|
+
# None chosen: no line, no notification
|
|
2305
|
+
STATE["print_task_config"].update(flow_calibrate=False)
|
|
2306
|
+
STATE["print_stats"] = ps("complete")
|
|
2307
|
+
await server.handlers["job_state:state_changed"](
|
|
2308
|
+
JobEvent.COMPLETE, {}, STATE["print_stats"])
|
|
2309
|
+
await asyncio.sleep(0.2)
|
|
2310
|
+
log.clear()
|
|
2311
|
+
await start_job(server)
|
|
2312
|
+
await asyncio.sleep(0.3)
|
|
2313
|
+
await c._on_status_update({"print_stats": {"info": {"current_layer": 1}}}, 0)
|
|
2314
|
+
await asyncio.sleep(0.2)
|
|
2315
|
+
check("none chosen: no line and no notification",
|
|
2316
|
+
len(log) == 1 and "Pre-print" not in log[0]["body"],
|
|
2317
|
+
[(e["title"], e["body"]) for e in log])
|
|
2318
|
+
|
|
2319
|
+
|
|
2246
2320
|
async def test_old_names():
|
|
2247
2321
|
"""0.1's names keep working: the remote method, the low-spool memory."""
|
|
2248
2322
|
data = os.path.join(WORK, "data")
|
|
@@ -2267,7 +2341,7 @@ async def run_component_tests():
|
|
|
2267
2341
|
test_faults_over_a_job, test_spool_switch, test_ace, test_file_pauses, test_file_mode, test_generic_printer, test_status_report, test_time_left, test_calibration, test_gotify, test_image_names, test_fault_emoji, test_send_gap, test_macro_notify, test_queue_line, test_chamber, test_filament_change, test_backup_order, test_console,
|
|
2268
2342
|
test_driver_hot,
|
|
2269
2343
|
test_print_by_object,
|
|
2270
|
-
test_no_secrets_in_logs, test_config_lines, test_old_names):
|
|
2344
|
+
test_no_secrets_in_logs, test_config_lines, test_old_names, test_preprint):
|
|
2271
2345
|
try:
|
|
2272
2346
|
await t()
|
|
2273
2347
|
except Exception as e: # report and carry on
|
|
@@ -111,6 +111,14 @@ def run_settings_tests():
|
|
|
111
111
|
check("options list the enabled notifications",
|
|
112
112
|
opts["started"].startswith("render, ntfys://ntfy.example.com/u1"),
|
|
113
113
|
opts.get("started"))
|
|
114
|
+
pp = st.Env(cameras=ENV.cameras, preprint=True)
|
|
115
|
+
check("pre-print calibrations complete: Print started's destination, "
|
|
116
|
+
"on printers that have them, while its checkbox is on",
|
|
117
|
+
"preprint_done" not in opts
|
|
118
|
+
and st.render_options(s, pp).get("preprint_done", "").startswith(
|
|
119
|
+
"render, ntfys://ntfy.example.com/u1")
|
|
120
|
+
and "preprint_done" not in st.render_options(
|
|
121
|
+
dict(s, preprint_done=False), pp))
|
|
114
122
|
comp = open(os.path.join(HERE, "..", "src", "pushraker",
|
|
115
123
|
"component.py")).read()
|
|
116
124
|
known = set(re.findall(r'(?:get|num)\(\s*"(\w+)"', comp))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|