small fix to the argsv and automated apt install of requirements

This commit is contained in:
Félix Boisselier
2024-01-08 00:26:44 +01:00
parent db57300eb2
commit f846534f0f
3 changed files with 31 additions and 14 deletions

View File

@@ -264,12 +264,10 @@ def main():
opts.add_option("-c", "--keep_csv", action="store_true", default=False, dest="keep_csv", opts.add_option("-c", "--keep_csv", action="store_true", default=False, dest="keep_csv",
help="weither or not to keep the CSV files alongside the PNG graphs image results") help="weither or not to keep the CSV files alongside the PNG graphs image results")
options, args = opts.parse_args() options, args = opts.parse_args()
if len(args) < 1:
opts.error("Incorrect number of arguments")
if options.type is None: if options.type is None:
opts.error("You must specify the type of output graph you want to produce (option -t)") opts.error("You must specify the type of output graph you want to produce (option -t)")
elif options.type.lower() not in ['belts', 'shaper', 'vibrations', 'axesmap', 'clean']: elif options.type.lower() is None or options.type.lower() not in ['belts', 'shaper', 'vibrations', 'axesmap', 'clean']:
opts.error("Type of output graph need to be in the list of 'belts', 'shaper', 'vibrations', 'axesmap' or 'clean'") opts.error("Type of output graph need to be in the list of 'belts', 'shaper', 'vibrations', 'axesmap' or 'clean'")
else: else:
graph_mode = options.type graph_mode = options.type

View File

@@ -21,19 +21,15 @@ Check out the **[detailed documentation of the Shake&Tune module here](./docs/RE
Follow these steps to install the Shake&Tune module in your printer: Follow these steps to install the Shake&Tune module in your printer:
1. Be sure to have a working accelerometer on your machine. You can follow the official [Measuring Resonances Klipper documentation](https://www.klipper3d.org/Measuring_Resonances.html) to configure one. Validate with an `ACCELEROMETER_QUERY` command that everything works correctly. 1. Be sure to have a working accelerometer on your machine. You can follow the official [Measuring Resonances Klipper documentation](https://www.klipper3d.org/Measuring_Resonances.html) to configure one. Validate with an `ACCELEROMETER_QUERY` command that everything works correctly.
1. Install the system libraries that are needed to run the custom Python scripts: 1. Install the Shake&Tune package by running over SSH on your printer:
```bash
sudo apt update && sudo apt install python3-venv libopenblas-dev libatlas-base-dev -y
```
1. Then, you can install the Shake&Tune package by running over SSH on your printer:
```bash ```bash
wget -O - https://raw.githubusercontent.com/Frix-x/klippain-shaketune/main/install.sh | bash wget -O - https://raw.githubusercontent.com/Frix-x/klippain-shaketune/main/install.sh | bash
``` ```
1. Finally, append the following to your `printer.cfg` file and restart Klipper (if prefered, you can include only the needed macros: using `*.cfg` is a convenient way to include them all at once): 1. Then, append the following to your `printer.cfg` file and restart Klipper (if prefered, you can include only the needed macros: using `*.cfg` is a convenient way to include them all at once):
``` ```
[include K-ShakeTune/*.cfg] [include K-ShakeTune/*.cfg]
``` ```
1. Optionally, if you want to get automatic updates, add the following to your `moonraker.cfg` file: 1. Finally, if you want to get automatic updates, add the following to your `moonraker.cfg` file:
``` ```
[update_manager Klippain-ShakeTune] [update_manager Klippain-ShakeTune]
type: git_repo type: git_repo
@@ -45,9 +41,6 @@ Follow these steps to install the Shake&Tune module in your printer:
install_script: install.sh install_script: install.sh
``` ```
> **Note**:
>
> If already using my old IS workflow scripts, please remove everything before installing this new module. This include the macros, the Python scripts, the `plot_graph.sh` and the `[gcode_shell_command plot_graph]` section that are not needed anymore.
## Usage ## Usage

View File

@@ -27,6 +27,32 @@ function preflight_checks {
echo "[ERROR] Klipper service not found, please install Klipper first!" echo "[ERROR] Klipper service not found, please install Klipper first!"
exit -1 exit -1
fi fi
install_package_requirements
}
# Function to check if a package is installed
function is_package_installed {
dpkg -s "$1" &> /dev/null
return $?
}
function install_package_requirements {
packages=("python3-venv" "libopenblas-dev" "libatlas-base-dev")
packages_to_install=""
for package in "${packages[@]}"; do
if is_package_installed "$package"; then
echo "$package is already installed"
else
packages_to_install="$packages_to_install $package"
fi
done
if [ -n "$packages_to_install" ]; then
echo "Installing missing packages: $packages_to_install"
sudo apt update && sudo apt install -y $packages_to_install
fi
} }
function check_download { function check_download {