From f846534f0f8b65400d0d160ef277ef77b960352b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Boisselier?= Date: Mon, 8 Jan 2024 00:26:44 +0100 Subject: [PATCH] small fix to the argsv and automated apt install of requirements --- K-ShakeTune/scripts/is_workflow.py | 4 +--- README.md | 15 ++++----------- install.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/K-ShakeTune/scripts/is_workflow.py b/K-ShakeTune/scripts/is_workflow.py index d5d50aa..dde04f6 100755 --- a/K-ShakeTune/scripts/is_workflow.py +++ b/K-ShakeTune/scripts/is_workflow.py @@ -264,12 +264,10 @@ def main(): 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") options, args = opts.parse_args() - if len(args) < 1: - opts.error("Incorrect number of arguments") if options.type is None: 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'") else: graph_mode = options.type diff --git a/README.md b/README.md index b7e11a0..429da33 100644 --- a/README.md +++ b/README.md @@ -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: 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: - ```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: + 1. Install the Shake&Tune package by running over SSH on your printer: ```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] ``` - 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] type: git_repo @@ -44,10 +40,7 @@ Follow these steps to install the Shake&Tune module in your printer: managed_services: klipper 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 diff --git a/install.sh b/install.sh index d6aa777..f2b99a2 100755 --- a/install.sh +++ b/install.sh @@ -27,6 +27,32 @@ function preflight_checks { echo "[ERROR] Klipper service not found, please install Klipper first!" exit -1 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 {