You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
change import statements and updated install script
change import statements and updated install script to support both python2 and python3 virtual environments
The change in the import statements is required to allow the extension to run properly under the python3 virtual environment for Klipper
Install script was updated and reorganized;
Added the following functions to the install script:
validate_printer_config_dir function, change_printer_config_dir function, check_env_version, validate_python3_installed,
change_py3, check_existing, create_requirements_file, prompt_user_update, validate_user_response,
copy_moonraker_update_file, and create_moonraker_file
Since this install script must handle both python2 and python3 virtual environments the install script will generate
the following files while the script is running based on the version of python running in Klipper virtual environment:
requirements.txt and extended_template_update.conf
The install script will now prompt the user to see if they want this extension automatically updated via moonraker's update manager.
If they answer Yes, then the install script will append an [include statement] to the EOF for the moonraker.conf
and save the extended_template_update.conf file to the printer's config directory.
Since moonraker changed directory structures, this install script will validate the printer's config file directory.
If the user is in python2 virtual env then the printer config directory should be /home/pi/klipper_config
If the user is in python3 virtual env then the printer config directory should be /home/pi/printer_data/config
This script defaults to a printer config directory of /home/pi/printer_data/config
Since this install script can now detect when this extension has already been installed, then need for another
script file for updates in no longer necessary. This install scripts' function called check_existing will produce
a 1 if the symbolic links to the .py files already exists. If the symbolic links are not present then check_existing
will return a 0. This logic is used to stop the script reinstalling the additional software packages after this
extension has been installed.
Since the moonraker update manager will automatically restart Klipper after an update, this script prevents
Klipper from restarting once the extension has been installed.
When an moonraker update does occur this script will re-verify all the directories and refresh the symbolic
links to this extensions .py files.
choose a different instantance variable name for the class in the module
Removed unnecessary spaces from the files
ensure the execute bit is set for install.sh file
Copy file name to clipboardExpand all lines: extended_macro/readme.md
+28-32Lines changed: 28 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# extended_macro
1
+
# Extended_Template
2
2
---
3
3
* Allow the use of custom Python functions in your Klipper macros by defining the functions in a YAML config file
4
4
* By default includes many additional modules and functions. See below for more information.
@@ -9,27 +9,24 @@
9
9
10
10
**Do not blindly download Python scripts, both for use in your macros and this script itself.** Read the script and ensure you understand what is going on. The scripts can be powerful and useful, but they can also be dangerous. If the script looks questionable, dangerous, or too confusing, it's better to assume that it is malicious.
11
11
12
-
**Installation:**
13
-
1.Write down the location of the following directories:
12
+
**What will happen when you run the Installation script:**
13
+
1.The script will determine if the following directories exist:
14
14
* Klipper Extras: Usually located at `/home/USER/klipper/klippy/extras`.
15
15
* Klippy Virtual Environment `bin` directory: Usually located at `/home/USER/klippy/bin`
16
-
2. Clone this repository or download `extended_macro.py`, `extended_template.py`, and `requirements.txt`
17
-
3. Move `extended_macro.py` and `extended_template.py` to your Klipper Extras folder.
18
-
4. Move `requirements.txt` to your home directory.
19
-
5. Run the following command, substituting `${KLIPPY_ENV}` with the Klippy Virtual Environment bin directory:
When defining the macro, use `extended_macro` as the config name instead of `gcode_macro`. To use your function, you will wrap the name with curly brackets (`{gcode_function_name_goes_here}`).
46
45
47
-
When defining the macro, use `extended_macro` as the config name instead of `gcode_macro`. To use your function, you will wrap the name with curly brackets (`{gcode_function_name_goes_here}`).
46
+
When you need the macro to be used on an timer instead of `extended_macro`use `delayed_extended` as the section definition.
48
47
49
48
---
50
49
**Defaults**
51
50
52
-
`extended_macro` comes with many default functions which do not need to be added or declared by the user.
51
+
`extended_macro`and `delayed_extended`comes with many default functions which do not need to be added or declared by the user.
53
52
54
53
---
55
54
@@ -60,46 +59,43 @@ On your Run the following commands in the command prompt of the Raspberry Pi run
Next, install Extended Macro using our install script. As with any script, please take time and read the script first so you can ensure the safety. Alternatively, if you understand how, you may download the files and manually install Extended Macro:
65
+
Next, install Extended Template using our installation script. As with any script, please take time and read the script first, so you can ensure the safety. Alternatively, if you understand how, you may download the files and manually install Extended Macro:
67
66
68
67
```BASH
69
68
./klipper_extras/install.sh
70
69
```
71
70
72
-
When the script finishes, copy the install script to your home directory so that we can edit it. On Line #3, you will need to adjust `FLAG=1` to `FLAG=0`. The reason for copying the file to your home directory is Moonraker will not like it if you edit the file while it is in the clone repo directory and will force you to overwrite the changes.
At this point, Extended Macro is ready to be used. If you wish to add this to your update manager, edit your `moonraker.conf` file and add the following:
With this above setup pointing the installation script to your home directory, anytime the extended_macro extension gets updated, your extended_macro_install.sh file will not be overwritten by the GitHub clone of the repo.
86
+
The script will automatically generate the `requirements.txt` file and (if the use chooses to have moonraker update this extension automatically) `extended_template_update.conf` file.
95
87
96
-
We want the `FLAG=0`to stay that way. You only need to install the additional software packages one time. Moonraker will take care of ensuring that the packages needed by the extension are updated (the `requirements` option takes care of that for you).
88
+
If the user chooses to have moonraker update this extension automatically, then the script will append the following to the end of your `moonraker.conf` file:
97
89
90
+
```INI
91
+
#add extended_template extension to Klipper
92
+
[include extended_template_update.conf]
93
+
```
98
94
---
99
95
100
96
*Custom Utility Functions*:
101
97
102
-
`update_gcode_variable(macro_name: str, variable: str, value: Any)`: Update a G-Code variable for any macro. Unlike `SET_GCODE_VARIABLE`, allows for non-literals to be passed and updated.
98
+
`update_gcode_variable(macro_name: str, variable: str, value: Any)`: Update a G-Code variable for any macro. Unlike `SET_GCODE_VARIABLE`, allows for non-literals to be passed and updated.
103
99
104
100
`update_dict(dict: dict, keys: Union[list, tuple, set, str], value: Any)`: Update the value of a dictionary. Allows for a nested value to be updated if a list, tuple, or set is passed for `keys`.
0 commit comments