diff --git a/README.md b/README.md
index ae75273..6597514 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@
diff --git a/print_debug.cfg b/print_debug.cfg
index 764c4c3..560903d 100644
--- a/print_debug.cfg
+++ b/print_debug.cfg
@@ -17,7 +17,7 @@
#####################################
## Print Debugging ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
## This file contains optional macros
diff --git a/print_extras.cfg b/print_extras.cfg
index d8af8df..ff31f99 100644
--- a/print_extras.cfg
+++ b/print_extras.cfg
@@ -17,7 +17,7 @@
#####################################
## Print Extras ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
## This file contains optional config
diff --git a/print_macros.cfg b/print_macros.cfg
index 6813f5a..3e00ad2 100644
--- a/print_macros.cfg
+++ b/print_macros.cfg
@@ -17,7 +17,7 @@
#####################################
## Print Macros ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
[include logging.cfg]
@@ -1506,56 +1506,58 @@ gcode:
description: Door is opened
variable_door: 0
gcode:
- {% set doorcfg = printer['gcode_macro _door_cfg'] %} ; get doorcfg variables
- {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables
- {% set door = params.DOOR|default(0) %} ; get door number
- {% set door_name = printcfg['door' + door] %} ; set door name
- SET_GCODE_VARIABLE MACRO=_open_door VARIABLE=door VALUE={door} ; store door
- {% if doorcfg.debounce == 0 %} ; check debounce
- M{printcfg.output|int} Door {door_name}: Open ; status output
- {printcfg.status_door_open} ; open door LEDs
- {% if custom_macro == True %} ; check for custom macro
- {printer['gcode_macro _printcfg'][door_macro]} ; run custom macro
- {% endif %}
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=debounce VALUE=1 ; set debounce state
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=state VALUE=1 ; set door state
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=1 ; set door bounce
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_door VALUE={door} ; set last door
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE=open ; set last state
- UPDATE_DELAYED_GCODE ID=door_debounce DURATION={(printcfg.door_debounce / 1000)|float} ; set debounce timer
- {% else %} ; bounced
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=1 ; set door bounce
+ {% set doorcfg = printer['gcode_macro _door_cfg'] %} ; get doorcfg variables
+ {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables
+ {% set door = params.DOOR|default(0) %} ; get door number
+ {% set door_name = printcfg['door' + door + '_name'] %} ; set door name
+ SET_GCODE_VARIABLE MACRO=_open_door VARIABLE=door VALUE={door} ; store door
+ logger title=Doors msg="Door: {door_name} opened" ; log door open
+ {% if doorcfg.debounce == 0 %} ; check debounce
+ M{printcfg.output|int} Door: {door_name} opened ; status output
+ {printcfg.status_door_open} ; open door LEDs
+ {% if custom_macro == True %} ; check for custom macro
+ {printer['gcode_macro _printcfg'][door_macro]} ; run custom macro
+ {% endif %}
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=state VALUE=1 ; set door state
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_door VALUE={door} ; set last door
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE="'open'" ; set last state
+ # SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=debounce VALUE=1 ; set debounce state
+ # SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=1 ; set door bounce
+ # UPDATE_DELAYED_GCODE ID=door_debounce DURATION={(printcfg.door_debounce / 1000)|float} ; set debounce timer
+ #{% else %} ; bounced
+ # SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=1 ; set door bounce
{% endif %}
[gcode_macro _close_door]
description: Door is closed
variable_door: 0
gcode:
- {% set doorcfg = printer['gcode_macro _door_cfg'] %} ; get doorcfg variables
- {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables
- {% set door = params.DOOR|default(0) %} ; get door number
- {% set door_name = printcfg['door' + door] %} ; set door name
- SET_GCODE_VARIABLE MACRO=_close_door VARIABLE=door VALUE={door} ; store door
+ {% set doorcfg = printer['gcode_macro _door_cfg'] %} ; get doorcfg variables
+ {% set printcfg = printer['gcode_macro _printcfg'] %} ; get printcfg variables
+ {% set door = params.DOOR|default(0) %} ; get door number
+ {% set door_name = printcfg['door' + door + '_name'] %} ; set door name
+ SET_GCODE_VARIABLE MACRO=_close_door VARIABLE=door VALUE={door} ; store door
+ logger title=Doors msg="Door: {door_name} closed" ; log door close
{% set door_macro = "door" + door|string + "_closed" %}
{% set custom_macro = True if printer['gcode_macro _printcfg'][door_macro] is defined else False %}
- {% if doorcfg.debounce == 0 %} ; check debounce
- M{printcfg.output|int} Door {door}: Closed ; status output
- {% if printer.virtual_sdcard.is_active == True %} ; printing state
- {printcfg.status_printing} ; closed door printing LEDs
- {% else %} ; idle state
- {printcfg.status_ready} ; closed door idle LEDs
+ {% if doorcfg.debounce == 0 %} ; check debounce
+ M{printcfg.output|int} Door: {door_name} closed ; status output
+ {% if printer.virtual_sdcard.is_active == True %} ; printing state
+ {printcfg.status_printing} ; closed door printing LEDs
+ {% else %} ; idle state
+ {printcfg.status_ready} ; closed door idle LEDs
{% endif %}
- {% if custom_macro == True %} ; check for custom macro
- {printer['gcode_macro _printcfg'][door_macro]} ; run custom macro
+ {% if custom_macro == True %} ; check for custom macro
+ {printer['gcode_macro _printcfg'][door_macro]} ; run custom macro
{% endif %}
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=debounce VALUE=1 ; set debounce state
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=state VALUE=0 ; set door state
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=0 ; set door bounce
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_door VALUE={door} ; set last door
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE=closed ; set last state
- UPDATE_DELAYED_GCODE ID=door_debounce DURATION={(printcfg.door_debounce / 1000)|float} ; set debounce timer
- {% else %} ; bounced
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=0 ; set door bounce
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=state VALUE=0 ; set door state
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_door VALUE={door} ; set last door
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE="'closed'" ; set last state
+ # SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=debounce VALUE=1 ; set debounce state
+ # SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=0 ; set door bounce
+ # UPDATE_DELAYED_GCODE ID=door_debounce DURATION={(printcfg.door_debounce / 1000)|float} ; set debounce timer
+ #{% else %} ; bounced
+ # SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=0 ; set door bounce
{% endif %}
@@ -1570,7 +1572,7 @@ gcode:
{% if doorcfg.bounce == 1 %} ; bounced open
SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=state VALUE=1 ; set door state
SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=1 ; set door bounce
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE=open ; set last state
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE="'open'" ; set last state
M{printcfg.output|int} Door Open ; status output
{printcfg.status_door_open} ; open door LEDs
{% if custom_macro == True %} ; check for custom macro
@@ -1579,7 +1581,7 @@ gcode:
{% else %} ; bounced closed
SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=state VALUE=0 ; set door state
SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=bounce VALUE=0 ; set door bounce
- SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE=closed ; set last state
+ SET_GCODE_VARIABLE MACRO=_door_cfg VARIABLE=last_state VALUE="'closed'" ; set last state
M{printcfg.output|int} Door Closed ; status output
{% if printer.virtual_sdcard.is_active == True %} ; printing state
{printcfg.status_printing} ; closed door printing LEDs
diff --git a/profiles/README.md b/profiles/README.md
index 14b8de4..adde8ee 100644
--- a/profiles/README.md
+++ b/profiles/README.md
@@ -20,7 +20,7 @@
diff --git a/profiles/default/config.cfg b/profiles/default/config.cfg
index fe8a547..151dcdd 100644
--- a/profiles/default/config.cfg
+++ b/profiles/default/config.cfg
@@ -17,7 +17,7 @@
#####################################
## Print Configuration ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# Profile:default
# Patch:4.0.0
diff --git a/profiles/default/variables.cfg b/profiles/default/variables.cfg
index c352e25..c740e8e 100644
--- a/profiles/default/variables.cfg
+++ b/profiles/default/variables.cfg
@@ -17,7 +17,7 @@
#####################################
## User Profile ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# Profile:default
# Patch:4.0.0
diff --git a/profiles/hephaestus/variables.cfg b/profiles/hephaestus/variables.cfg
index 4a2e0ce..2a34c47 100644
--- a/profiles/hephaestus/variables.cfg
+++ b/profiles/hephaestus/variables.cfg
@@ -17,7 +17,7 @@
#####################################
## User Profile ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# Profile:hephaestus
# Patch:4.0.0
@@ -38,40 +38,73 @@
## printcfg Configuration Variables
## Variables file version
+## NOTE: This value should match the versions above
+## If it does not, the profile may not load
variable_version: '4.0.0'
## Default temperatures
+## NOTE: These values are used for the default
+## temperatures for the printer. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_extruder_temp: 240
variable_extruder_pretemp: 150
variable_bed_temp: 100
## Default Offset
-variable_z_offset: 0.0
+## NOTE: This value is used for the default
+## gcode z-offset for the printer. It can
+## be overridden by the slicer or by the
+## user at runtime.
+variable_z_offset: 0.0 ; Default z-offset adjustment to be applied to prints
+variable_start_offset: False ; If True, the z-offset will be applied at the start of the print
+variable_end_offset: True ; If True, the z-offset will be removed at the end of the print
+variable_offset_store: False ; If True, the z-offset will be saved to the config at the end of a print
## Chamber Variables
+## NOTE: These values are used for the default
+## specifications of the chamber. They can
+## be overridden by the slicer or by the
+## user at runtime.
+variable_chamber: True
variable_chamber_type: 'temperature_sensor'
variable_chamber_name: 'chamber'
variable_chamber_temp: 35
variable_chamber_time: 10
## Soaking Variables
+## NOTE: These values are used for the default
+## behavior of the heat soak feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_heat_soak: True
variable_time_soak: False
variable_temp_soak: True
## Bed Fan Variables
+## NOTE: These values are used to configure the
+## bed fan. They can be overridden by the
+## slicer or by the user at runtime.
variable_bed_fan: True
variable_bed_fan_fast: 'BEDFANSFAST'
variable_bed_fan_slow: 'BEDFANSSLOW'
variable_bed_fan_stop: 'BEDFANSOFF'
## Idle Time Variables
+## NOTE: These values are used for the default
+## behavior of the idle time feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_idle_time: 900
variable_m600_idle_time: 3600
variable_pause_idle_time: 18000
variable_soak_idle_time: 18000
## Idle Action Variables
+## NOTE: These values are used for the default
+## behavior of the idle action feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_idle_extruder: True
variable_idle_bed: True
variable_idle_chamber: True
@@ -79,6 +112,10 @@ variable_idle_steppers: True
variable_idle_power: True
## Parking Variables
+## NOTE: These values are used for the default
+## behavior of the nozzle parking feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_park_x: 25
variable_park_y: 300
variable_park_z: 50
@@ -89,19 +126,35 @@ variable_park_extrude: 1.0
variable_park_base: '_TOOLHEAD_PARK_PAUSE_CANCEL'
## Preheat Parking Variables
+## NOTE: These values are used for the default
+## behavior of the preheat parking feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_preheat_x: 145
variable_preheat_y: 153
variable_preheat_z: 10
## Maintenance Parking Variables
+## NOTE: These values are used for the default
+## behavior of the maintenance parking feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
+## NOTE: Setting any of these to -1 will disable
+## custom parking coordinates for maintenance.
+## In that case, the centers of all axes will
+## be used.
variable_maint_x: -1
variable_maint_y: -1
variable_maint_z: -1
## Homing Variables
+## NOTE: These values are used for the default
+## behavior of the homing feature. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_home_x: 145
variable_home_y: 153
-variable_pre_home_z: 2.0 ; Enable force_move to use this feature
+variable_pre_home_z: 2.0 ; NOTE: Enable force_move to use this feature
variable_post_home_z: 10
variable_home_travel_speed: 10000
variable_home_z_speed: 1000
@@ -111,23 +164,37 @@ variable_sensorless_home: True
variable_home_current: 0.7
## Homing Macros
+## NOTE: These values are used for the default
+## behavior of the homing macros. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_home_x_macro: '_HOME_X'
variable_home_y_macro: '_HOME_Y'
variable_home_z_macro: '_HOME_Z'
## Pause Macros
+## NOTE: These values are used for the default
+## behavior of the pause/resume function. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_pause_macro: 'PAUSE'
variable_pause_no_park: 'PAUSE_BASE'
## Speed Variables
+## NOTE: These values are used for the default
+## speed factor and travel speed. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_default_speed_factor: 100
-variable_start_offset: False
variable_start_speed_factor: False
-variable_end_offset: True
variable_end_speed_factor: True
variable_travel_speed: 300
## Filter Variables
+## NOTE: These values are used for the default
+## behavior of the air filter. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_nevermore: True
variable_nevermore_name: 'nevermore'
variable_nevermore_type: 'fan_generic'
@@ -139,26 +206,45 @@ variable_hours_until_replacement: 100
variable_filter_replacement: 'M118 Replace Filter Media'
## Controller fan Variables
+## NOTE: These values are used to configure the
+## controller fan. They can be overridden
+## by the slicer or by the user at runtime.
variable_controller_fan: False
variable_controller_fan_start: 'BEDFANSFAST'
variable_controller_fan_stop: 'BEDFANSOFF'
## Exhaust Fan Variables
+## NOTE: These values are used to configure the
+## exhaust fan. They can be overridden by the
+## slicer or by the user at runtime.
variable_exhaust_fan: False
variable_exhaust_fan_start: 'EXHAUST_FAN_FAST'
variable_exhaust_fan_stop: 'EXHAUST_FAN_OFF'
variable_exhaust_time: 600
## Docking Probe Variables
+## NOTE: These values are used to define the
+## docking probe behavior. They can be
+## overridden by the slicer or by the
+## user at runtime.
variable_docking_probe: False
variable_attach_macro: 'Attach_Probe_Lock'
variable_dock_macro: 'Dock_Probe_Unlock'
## Z Calibration Variables
+## NOTE: These values are used to define the
+## z calibration behavior. They can be
+## overridden by the slicer or by the
+## user at runtime.
+variable_auto_z_calibrate: False
variable_z_tilt: False
variable_qgl: True
## Meshing Variables
+## NOTE: These values are used to define the
+## meshing behavior. They can be
+## overridden by the slicer or by the
+## user at runtime.
variable_bed_mesh: True
variable_mesh_adaptive: True
variable_load_mesh: False
@@ -168,6 +254,10 @@ variable_mesh_fuzz_min: 0 # If enabled, the minimum amount in
variable_mesh_fuzz_max: 4 # If enabled, the maximum amount in mm a probe point can be randomized, default is 4.
## Nozzle Cleaning Variables
+## NOTE: These values are used to define the
+## nozzle cleaning/brushing behavior.
+## They can be overridden by the slicer
+## or by the user at runtime.
variable_cleaning: True
variable_clean_probe: True
variable_clean_end: False
@@ -186,6 +276,11 @@ variable_clean_temp: 180
variable_clean_hot: True
## Purging Variables
+## NOTE: These values are used to define the
+## behavior of the purge macro and the
+## adaptive purge feature. They can be
+## overridden by the slicer or by the
+## user at runtime.
variable_purging: True
variable_purge_macro: 'ADAPTIVE_PURGE'
variable_purge_adaptive: True
@@ -201,6 +296,10 @@ variable_purge_size: 10
variable_purge_debug: False
## End Gcode Variables
+## NOTE: These values are used to define the
+## behavior of the end gcode macros.
+## They can be overridden by the slicer
+## or by the user at runtime.
variable_end_print: True
variable_end_retract: True
variable_end_retract_length: 15
@@ -210,6 +309,10 @@ variable_off_macro: 'POWER_OFF'
variable_end_unload: False
## Filament Change Variables
+## NOTE: These values are used to define the
+## behavior of the filament change macros.
+## They can be overridden by the slicer
+## or by the user at runtime.
variable_m600: 'M600'
variable_auto_filament_sensor: False
variable_auto_filament_delay: 5
@@ -228,10 +331,18 @@ variable_auto_load: True
## Status Output Variables
+## NOTE: These values are used to define the
+## console/display status output behavior.
+## They can be overridden by the slicer
+## or by the user at runtime.
variable_output: 118 # Select 116, 117, or 118 to specify output method for feedback
variable_error_output: 118
## LED Status Variables
+## NOTE: These values are used to define the
+## LED status output behavior. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_led_status: True # Use LED Status macros such as on the stealthburner
variable_status_ready: '_STATUS_READY'
variable_status_busy: '_STATUS_BUSY'
@@ -249,6 +360,10 @@ variable_status_error: '_STATUS_ERROR'
variable_status_printing: '_STATUS_PRINTING'
## Audio Status Variables
+## NOTE: These values are used to define the
+## audio status output behavior. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_audio_status: True # Use audio feedback macros
variable_start_audio: '_PRINT_START_TUNE'
variable_error_audio: '_GAME_OVER_TUNE'
@@ -258,19 +373,46 @@ variable_m600_audio: '_CHANGE_TUNE'
variable_alert_freq: 5
## Telegram Status Variables
+## NOTE: These values are used to define the
+## Telegram status output behavior. They can
+## be overridden by the slicer or by the
+## user at runtime.
variable_use_telegram: False # Use Telegram feedback macros
variable_telegram_runout: 'TELEGRAM_FILAMENT_RUNOUT'
+
## Door Switch Variables
-variable_doors: 1 ; Number of doors (0, 1 or 2)
-variable_door1: 'doors' ; Name of first door switch
-variable_door2: 'right_door' ; Name of second door switch
-## Note: Additional door switches can be added here (e.g. variable_door3, variable_door4, etc.)
+
+## Note: Define the number of doors and their names (mandatory) and open/closed macros (optional)
+## You may define as many doors as you like (e.g. variable_doors: 42)
+## Each door must have a name (e.g. variable_door1_name: 'left_door')
+## Each door may optionally have custom macros for open and closed (e.g. variable_door1_open: 'M116')
+
+variable_doors: 1 ; Number of doors (0, 1 or 2) (set to 0 to disable)
+
+variable_door1_name: 'Left' ; Name of first door switch
+variable_door1_open: 'M116' ; Custom macro for open door1 (set to 'M116' to disable)
+variable_door1_closed: 'M116' ; Custom macro for closed door1 (set to 'M116' to disable)
+
+variable_door2_name: 'Right' ; Name of second door switch
+variable_door2_open: 'M116' ; Custom macro for open door2 (set to 'M116' to disable)
+variable_door2_closed: 'M116' ; Custom macro for closed door2 (set to 'M116' to disable)
+## Note: Additional door switches may be defined here
+
+# These variables apply to all doors defined above
variable_door_debounce: 250 ; Debounce time for door switch (ms)
variable_status_door_open: '_STATUS_BRIGHT' ; Status to show when door is open
variable_door_open_gcode: 'M116' ; Custom macro for open doors (set to 'M116' to disable)
variable_door_closed_gcode: 'M116' ; Custom macro for closed doors (set to 'M116' to disable)
+## Debugging Variables
+## NOTE: These variables configure debugging
+## behavior. They are used to enable
+## or disable debugging output and
+## to define the debug output level.
+variable_debugging: True
+variable_debug_level: 0
+
# End Custom Variables #
#############################################################################################################
@@ -296,7 +438,14 @@ gcode: # No gcode needed
-## Mainsail Client Macro Variables
+## Web Client Macro Variables
+## NOTE: These values are used to define additional
+## variables for the web client. They will affect
+## the behavior of compatible web clients (Fluidd/Mainsail/etc)
+
+## printcfg is designed to work alongside the macros distributed
+## with Mainsail/Fluidd. If you are using a different web client,
+## you may need to modify the macros to work with your client.
[gcode_macro _CLIENT_VARIABLE]
variable_use_custom_pos : False ; use custom park coordinates for x,y [True/False]
variable_custom_park_x : 50.0 ; custom x position; value must be within your defined min and max of X
@@ -422,4 +571,4 @@ gcode:
{% if printcfg._telegram_runout is not defined %}
M{printcfg.error_output} "WARNING: _telegram_runout macro does not exist!"
{% endif %}
- {% endif %}
+ {% endif %}
\ No newline at end of file
diff --git a/scripts/change_profile.sh b/scripts/change_profile.sh
index 1fea609..9c54f03 100644
--- a/scripts/change_profile.sh
+++ b/scripts/change_profile.sh
@@ -19,7 +19,7 @@
#####################################
## Printcfg Profile Change ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# This script will change the user profile to the specified profile.
diff --git a/scripts/install.sh b/scripts/install.sh
index 99c8c53..8e46193 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -19,7 +19,7 @@
#####################################
## Printcfg Install Script ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# This script will download and install the printcfg package from GitHub.
@@ -315,7 +315,7 @@ fi
# Set branch in moonraker-printcfg.conf
echo "Setting branch in moonraker config..."
# Define search pattern
-branch_pattern="primary_branch:*"
+branch_pattern="primary_branch:"
# Set branch to current branch
python3 $home/$repo/scripts/search_replace.py "$branch_pattern" "$branch_pattern $branch" "$config/moonraker-$repo.conf"
diff --git a/scripts/log_logger.py b/scripts/log_logger.py
deleted file mode 100644
index 8d666f4..0000000
--- a/scripts/log_logger.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# Copyright (C) 2023 Chris Laprade (chris@rootiest.com)
-#
-# This file is part of printcfg.
-#
-# printcfg is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# printcfg is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with printcfg. If not, see .
-
-import sys
-from watchdog.observers import Observer
-from watchdog.events import FileSystemEventHandler
-
-class LogFileHandler(FileSystemEventHandler):
- def __init__(self, watched_file, output_file):
- self.watched_file = watched_file
- self.output_file = output_file
- self.previous_line = None
-
- def on_modified(self, event):
- if event.src_path == self.watched_file:
- try:
- with open(self.watched_file, 'r') as f:
- current_line = f.readline().strip()
- log_index = current_line.find("log = ")
- if log_index != -1:
- log_text = current_line[log_index + len("log = "):]
- if log_text != self.previous_line:
- with open(self.output_file, 'a') as output:
- output.write(log_text + '\n')
- self.previous_line = log_text
- except IOError as e:
- print("IOError: " + e.strerror)
-
-# Example usage:
-watched_file = 'variables.cfg'
-output_file = 'printcfg.log'
-
-# Check for arguments:
-if len(sys.argv) > 1:
- if sys.argv[1] == '-h' or sys.argv[1] == '--help':
- print('Usage: python3 log_logger.py ')
- sys.exit(0)
- else:
- if len(sys.argv) > 2:
- watched_file = sys.argv[1]
- output_file = sys.argv[2]
-
-
-
-event_handler = LogFileHandler(watched_file, output_file)
-observer = Observer()
-observer.schedule(event_handler, path='.', recursive=False)
-observer.start()
-
-try:
- while True:
- pass
-except KeyboardInterrupt:
- observer.stop()
-
-observer.join()
diff --git a/scripts/patch.sh b/scripts/patch.sh
index db6a73d..5e6b890 100644
--- a/scripts/patch.sh
+++ b/scripts/patch.sh
@@ -19,7 +19,7 @@
#####################################
## Printcfg Patch Script ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# This script will apply version patches to the user profile and user config.
diff --git a/scripts/read_patch_notes.py b/scripts/read_patch_notes.py
index d5a3b30..69f74a0 100644
--- a/scripts/read_patch_notes.py
+++ b/scripts/read_patch_notes.py
@@ -21,14 +21,14 @@
# This script reads the patch notes file and returns the highest version number.
-import os
import sys
import re
def find_highest_version(file_name):
+ """Finds highest version in patch notes."""
highest_version = None
- with open(file_name, 'r') as file:
+ with open(file_name, 'r', encoding="utf-8") as file:
content = file.read()
pattern = r'(\d+\.\d+\.\d+):'
@@ -42,6 +42,6 @@ def find_highest_version(file_name):
# Test the function
-file_name = sys.argv[1]
-highest_version = find_highest_version(file_name)
-print(highest_version)
+f_name = sys.argv[1]
+h_version = find_highest_version(f_name)
+print(h_version)
diff --git a/scripts/search_replace.py b/scripts/search_replace.py
index 73a7134..d04eda6 100644
--- a/scripts/search_replace.py
+++ b/scripts/search_replace.py
@@ -19,7 +19,8 @@
#!/usr/bin/env python3
-# This code searches for a string in a file and replaces the whole line containing the string with a different string.
+# This code searches for a string in a file and replaces the whole line
+# containing the string with a different string.
# The search is case sensitive.
# It will add the line if it does not exist.
# It will overwrite the file with the new contents.
@@ -44,6 +45,7 @@
import getpass
import re
import logging
+import datetime
logger: logging.Logger = logging.getLogger(__name__)
@@ -53,6 +55,18 @@
# Set the logfile
logfile = f"{user_home}/printcfg/logs/search_replace.log"
+# Check the date of the first log entry
+# If it is older than 30 days, delete the logfile
+if os.path.exists(logfile):
+ with open(logfile, "r", encoding="utf-8") as file:
+ first_line = file.readline()
+ if first_line:
+ first_line = first_line.split(" - ")[0]
+ first_line = datetime.datetime.strptime(first_line, "%Y-%m-%d %H:%M:%S,%f")
+ thirty_days_ago = datetime.datetime.now() - datetime.timedelta(days=30)
+ if first_line < thirty_days_ago:
+ os.remove(logfile)
+
# Set the logging level
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
@@ -61,6 +75,59 @@
logger.addHandler(handler)
+def simple_search_and_replace(search_text, replace_text, file_name):
+ """Searches for the line containing the search_text and replaces the whole line with the replace_text and saves the updated file over the original.
+
+ Args:
+ search_text: The text to search for.
+ replace_text: The text to replace the search_text with.
+ file_name: The name of the file to search and replace.
+
+ Returns:
+ A status indicating whether the change was successful.
+ """
+
+ # Log the input
+ logger.debug(
+ "search_and_replace() called with: search_text=%s, replace_text=%s, file_name=%s",
+ search_text,
+ replace_text,
+ file_name,
+ )
+
+ if search_text is None or replace_text is None or file_name is None:
+ logger.error(
+ "search_and_replace() failed due to invalid input: search_text=%s, replace_text=%s, file_name=%s",
+ search_text,
+ replace_text,
+ file_name,
+ )
+ return False
+
+ logger.debug("search_and_replace() opened the file %s", file_name)
+ with open(file_name, "r", encoding="utf-8") as f:
+ lines = f.readlines()
+
+ found = False
+ for i, line in enumerate(lines):
+ if search_text in line:
+ lines[i] = replace_text + '\n'
+ found = True
+ logger.debug("search_and_replace() found the search_text %s", search_text)
+ break
+
+ if not found:
+ logger.debug("search_and_replace() did not find the search_text %s", search_text)
+ lines.insert(0, replace_text + "\n")
+ logger.debug("search_and_replace() inserted the replace_text %s", replace_text)
+
+ with open(file_name, "w", encoding="utf-8") as f:
+ f.writelines(lines)
+ logger.debug("search_and_replace() wrote the file %s", file_name)
+
+ return found
+
+
def search_and_replace(search_text: str, replace_text: str, file_name: str) -> bool:
"""Searches for the line containing the search_text and replaces the whole line with the replace_text and saves the updated file over the original.
@@ -93,7 +160,7 @@ def search_and_replace(search_text: str, replace_text: str, file_name: str) -> b
# Open the file
logger.debug("search_and_replace() opened the file %s", file_name)
- with open(file_name, "r") as f:
+ with open(file_name, "r", encoding="utf-8") as f:
lines = f.readlines()
# Search the file for the search_text
@@ -110,10 +177,9 @@ def search_and_replace(search_text: str, replace_text: str, file_name: str) -> b
# Write the file
logger.debug("search_and_replace() wrote the file %s", file_name)
- with open(file_name, "w") as f:
+ with open(file_name, "w", encoding="utf-8") as f:
f.writelines(lines)
- return True
return found
@@ -126,11 +192,11 @@ def search_and_replace(search_text: str, replace_text: str, file_name: str) -> b
print(' python3 search_replace.py "version" "version: 1.0.0" "patch_notes.txt"')
sys.exit(1)
-search_text = sys.argv[1]
-replace_text = sys.argv[2]
-file_name = sys.argv[3]
+s_text = sys.argv[1]
+r_text = sys.argv[2]
+f_name = sys.argv[3]
-status = search_and_replace(search_text, replace_text, file_name)
+status = simple_search_and_replace(s_text, r_text, f_name)
if status:
print("The change was successful.")
else:
diff --git a/scripts/setup.sh b/scripts/setup.sh
index 4e690e2..87e75a9 100644
--- a/scripts/setup.sh
+++ b/scripts/setup.sh
@@ -19,7 +19,7 @@
#####################################
## Printcfg Setup Script ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
# This script will check the user profile and update it if necessary.
@@ -60,12 +60,14 @@ old_user_cfg=$config/$repo/user_config.cfg
# Check if any parameters were provided
if [ $# -eq 0 ]
then
+ src_cfg=$config/$repo/profiles/$default_src/config.cfg
src_vars=$config/$repo/profiles/$default_src/variables.cfg
src_path=$config/$repo/profiles/$default_src
else
# Set the src_vars file
if [ -n "$1" ]
then
+ src_cfg=$config/$repo/profiles/$1/config.cfg
src_vars=$config/$repo/profiles/$1/variables.cfg
src_path=$config/$repo/profiles/$1
fi
@@ -91,119 +93,173 @@ else
fi
fi
-echo "Checking user config..."
-
-# Check that user config exists
-if [ ! -f $user_cfg ]
+# Check for force parameter
+if [ "$2" == "force" ]
then
- # Check if old user config exists
- if [ -f $old_user_cfg ]
+ echo -e "\e[31mChanging user profile to $default_src.\e[0m"
+ echo
+ echo "Updating user config..."
+ # Check if src_cfg exists
+ if [ -f $src_cfg ]
then
- echo -e "\e[31mUser config location is out of date.\e[0m"
- mv $old_user_cfg $user_cfg
- # Verify move was successful
+ # Check if user config exists
if [ -f $user_cfg ]
then
- echo "User config moved to $config/user_config.cfg"
- else
- echo -e "\e[31mUser config move failed.\e[0m"
- exit 1
- fi
- # Check if old include line exists in printer.cfg
- echo "Checking printer.cfg include line..."
- if grep -qFx "[include $repo/user_config.cfg]" "$printer"
- then
- echo -e "\e[31mInclude line is out of date.\e[0m"
- # Remove old include line
- sed -i '/\[include $repo\/user_config.cfg\]/d' "$printer"
- # Add new include line
- sed -i '1s/^/[include user_config.cfg]\n/' "$printer"
- # Verify include line was added
- if grep -qFx "[include user_config.cfg]" "$printer"
+ # Remove old user config
+ rm $user_cfg
+ # Verify removal was successful
+ if [ ! -f $user_cfg ]
then
- echo "Include line updated."
- # User config is up to date
- echo -e "\e[32mUser config is now up to date.\e[0m"
+ echo "Old user config removed."
+ # Copy new user config
+ cp $src_cfg $user_cfg
+ # Verify copy was successful
+ if [ -f $user_cfg ]
+ then
+ echo "New user config copied."
+ # User config is up to date
+ echo -e "\e[32mUser config is now up to date.\e[0m"
+ else
+ echo -e "\e[31mUser config copy failed.\e[0m"
+ exit 1
+ fi
else
- echo -e "\e[31mInclude line update failed.\e[0m"
+ echo -e "\e[31mOld user config removal failed.\e[0m"
exit 1
fi
else
- if grep -qFx "[include user_config.cfg]" "$printer"
+ echo -e "\e[31mUser config does not exist.\e[0m"
+ exit 1
+ fi
+ else
+ echo -e "\e[31mSource config does not exist.\e[0m"
+ exit 1
+ fi
+ # Check if src_vars exists
+ if [ -f $src_vars ]
+ then
+ # Check if user vars exists
+ if [ -f $user_vars ]
+ then
+ # Remove old user vars
+ rm $user_vars
+ # Verify removal was successful
+ if [ ! -f $user_vars ]
then
- echo -e "\e[32mUser config is up to date.\e[0m"
+ echo "Old user vars removed."
+ # Copy new user vars
+ cp $src_vars $user_vars
+ # Verify copy was successful
+ if [ -f $user_vars ]
+ then
+ echo "New user vars copied."
+ # User vars is up to date
+ echo -e "\e[32mUser vars is now up to date.\e[0m"
+ else
+ echo -e "\e[31mUser vars copy failed.\e[0m"
+ exit 1
+ fi
else
- echo -e "\e[31mInclude line does not exist.\e[0m"
+ echo -e "\e[31mOld user vars removal failed.\e[0m"
exit 1
fi
+ else
+ echo -e "\e[31mUser vars does not exist.\e[0m"
+ exit 1
fi
else
- echo -e "\e[31mUser config does not exist.\e[0m"
+ echo -e "\e[31mSource vars does not exist.\e[0m"
exit 1
fi
else
- # User config is up to date
- echo -e "\e[32mUser config is up to date.\e[0m"
-fi
-
-echo
-echo "Checking user profile..."
-
-# Check that user profile exists
-if [ ! -f $user_vars ]
-then
- # Check if old user profile exists
- if [ -f $old_user_vars ]
+ echo "Checking user config..."
+ # Check that user config exists
+ if [ ! -f $user_cfg ]
then
- echo -e "\e[31mUser profile location is out of date.\e[0m"
- mv $old_user_vars $user_vars
- # Verify move was successful
- if [ -f $user_vars ]
+ # Check if old user config exists
+ if [ -f $old_user_cfg ]
then
- echo "User profile moved to $config/user_profile.cfg"
+ echo -e "\e[31mUser config location is out of date.\e[0m"
+ mv $old_user_cfg $user_cfg
+ # Verify move was successful
+ if [ -f $user_cfg ]
+ then
+ echo "User config moved to $config/user_config.cfg"
+ else
+ echo -e "\e[31mUser config move failed.\e[0m"
+ exit 1
+ fi
+ # Check if old include line exists in printer.cfg
+ echo "Checking printer.cfg include line..."
+ if grep -qFx "[include $repo/user_config.cfg]" "$printer"
+ then
+ echo -e "\e[31mInclude line is out of date.\e[0m"
+ # Remove old include line
+ sed -i '/\[include $repo\/user_config.cfg\]/d' "$printer"
+ # Add new include line
+ sed -i '1s/^/[include user_config.cfg]\n/' "$printer"
+ # Verify include line was added
+ if grep -qFx "[include user_config.cfg]" "$printer"
+ then
+ echo "Include line updated."
+ # User config is up to date
+ echo -e "\e[32mUser config is now up to date.\e[0m"
+ else
+ echo -e "\e[31mInclude line update failed.\e[0m"
+ exit 1
+ fi
+ else
+ if grep -qFx "[include user_config.cfg]" "$printer"
+ then
+ echo -e "\e[32mUser config is up to date.\e[0m"
+ else
+ echo -e "\e[31mInclude line does not exist.\e[0m"
+ exit 1
+ fi
+ fi
else
- echo -e "\e[31mUser profile move failed.\e[0m"
+ echo -e "\e[31mUser config does not exist.\e[0m"
exit 1
fi
else
- echo -e "\e[31mUser profile does not exist.\e[0m"
- exit 1
+ # User config is up to date
+ echo -e "\e[32mUser config is up to date.\e[0m"
fi
-fi
-
-# Find version of user profile
-user_vars_version=$(grep -oP '(variable_version: ).*' $user_vars)
-user_vars_version=${user_vars_version#variable_version: }
-src_vars_version=$(grep -oP '(variable_version: ).*' $src_vars)
-src_vars_version=${src_vars_version#variable_version: }
-
-# Check if user profile is up to date
-if [ "$user_vars_version" != "$src_vars_version" ]; then
- if [ -n "$2" ]
+
+ echo
+ echo "Checking user profile..."
+
+ # Check that user profile exists
+ if [ ! -f $user_vars ]
then
- # If second argument is "force"
- if [ "$2" == "force" ]
+ # Check if old user profile exists
+ if [ -f $old_user_vars ]
then
- echo -e "\e[31mUser profile is not up to date.\e[0m"
- echo "User version: $user_vars_version"
- echo "Source version: $src_vars_version"
- # Fix the user profile
- echo "Updating user profile..."
- cp $src_vars $user_vars
- # update user_vars_version variable
- user_vars_version=$(grep -oP '(variable_version: ).*' $user_vars)
- user_vars_version=${user_vars_version#variable_version: }
- echo "User profile updated."
- echo
+ echo -e "\e[31mUser profile location is out of date.\e[0m"
+ mv $old_user_vars $user_vars
+ # Verify move was successful
+ if [ -f $user_vars ]
+ then
+ echo "User profile moved to $config/user_profile.cfg"
+ else
+ echo -e "\e[31mUser profile move failed.\e[0m"
+ exit 1
+ fi
else
- echo -e "\e[31mUser profile is not up to date.\e[0m"
- echo "User version: $user_vars_version"
- echo "Source version: $src_vars_version"
- echo -e "\e[31mPlease update the user profile.\e[0m"
- echo
- echo -e "\e[31mSetup checks failed.\e[0m"
+ echo -e "\e[31mUser profile does not exist.\e[0m"
+ exit 1
fi
- else
+ fi
+
+ # Find version of user profile
+ user_vars_version=$(grep -oP '(variable_version: ).*' $user_vars)
+ user_vars_version=${user_vars_version#variable_version: }
+ src_vars_version=$(grep -oP '(variable_version: ).*' $src_vars)
+ src_vars_version=${src_vars_version#variable_version: }
+
+ # Check if user profile is up to date
+
+ if [ "$user_vars_version" != "$src_vars_version" ]; then
echo
echo -e "\e[31mUser profile is not up to date.\e[0m"
echo "User version: $user_vars_version"
@@ -221,12 +277,13 @@ if [ "$user_vars_version" != "$src_vars_version" ]; then
echo
bash $home/$repo/scripts/patch.sh
exit 1
+ else
+ echo -e "\e[32mUser profile is up to date.\e[0m"
+ echo "User version: $user_vars_version"
fi
-else
- echo -e "\e[32mUser profile is up to date.\e[0m"
- echo "User version: $user_vars_version"
fi
+
# Check that printcfg service is enabled
echo
echo "Checking $repo service..."
diff --git a/src/gen_service.py b/src/gen_service.py
index aa0cbcc..ff1b55d 100644
--- a/src/gen_service.py
+++ b/src/gen_service.py
@@ -79,7 +79,7 @@
print(f"Working directory: {os.path.dirname(SERVICE_PATH)}")
os.makedirs(os.path.dirname(SERVICE_FILE), exist_ok=True)
- with open(SERVICE_FILE, "w") as service:
+ with open(SERVICE_FILE, "w", encoding="utf-8") as service:
service.write(service_content)
# Set the appropriate permissions for the service configuration file
diff --git a/src/mooncfg.conf b/src/mooncfg.conf
index 37c523f..8c841a2 100644
--- a/src/mooncfg.conf
+++ b/src/mooncfg.conf
@@ -1,6 +1,6 @@
#####################################
## Printcfg Moonraker ##
-## Version 4.0.0 2023-6-1 ##
+## Version 4.0.0 2023-6-5 ##
#####################################
## Manage updates for Rootiest printcfg Suite for Klipper
diff --git a/src/printcfg.py b/src/printcfg.py
index b5f070e..9f586ce 100755
--- a/src/printcfg.py
+++ b/src/printcfg.py
@@ -33,6 +33,7 @@
import getpass
import subprocess
import logging
+import datetime
logger: logging.Logger = logging.getLogger(__name__)
@@ -48,12 +49,24 @@
# Set the logfile
logfile = f"{user_home}/printcfg/logs/printcfg.log"
+# Check the date of the first log entry
+# If it is older than 30 days, delete the logfile
+if os.path.exists(logfile):
+ with open(logfile, "r", encoding="utf-8") as file:
+ first_line = file.readline()
+ if first_line:
+ first_line = first_line.split(" - ")[0]
+ first_line = datetime.datetime.strptime(first_line, "%Y-%m-%d %H:%M:%S,%f")
+ thirty_days_ago = datetime.datetime.now() - datetime.timedelta(days=30)
+ if first_line < thirty_days_ago:
+ os.remove(logfile)
+
# Check if the logfile exists
if not os.path.exists(f"{user_home}/printcfg/logs/"):
# Create the log directory
os.mkdir(f"{user_home}/printcfg/logs/")
# Create the logfile
- with open(logfile, "w") as file:
+ with open(logfile, "w", encoding="utf-8") as file:
pass
# Set the logging level
@@ -67,7 +80,7 @@
def find_profile(path):
logger.debug("Searching for profile name in file: {}".format(path))
# Find the profile name (Eg: '# Profile: default' = 'default')
- with open(path, "r") as file:
+ with open(path, "r", encoding="utf-8") as file:
for line in file:
if line.startswith("# Profile: "):
logger.debug("Found profile name: {}".format(line[11:].strip()))