From bc4b07e658fe287951a372df236edd62b522af97 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 11 Nov 2022 17:04:12 -0800 Subject: [PATCH] Update readme, move scripts, bug fixes --- README.md | 33 +++++++++++++++++-- .../joy-bonnet.sh | 0 .../libgpiod.sh | 0 .../rpi-pin-kernel-firmware.sh | 0 raspi-blinka.py | 3 +- rpi_pin_kernel_firmware.py | 14 ++++---- 6 files changed, 38 insertions(+), 12 deletions(-) rename joy-bonnet.sh => converted_shell_scripts/joy-bonnet.sh (100%) rename libgpiod.sh => converted_shell_scripts/libgpiod.sh (100%) rename rpi-pin-kernel-firmware.sh => converted_shell_scripts/rpi-pin-kernel-firmware.sh (100%) diff --git a/README.md b/README.md index 886839f..220a979 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,35 @@ Some scripts for helping install Adafruit HATs, bonnets, add-on's, & friends! -Based heavily on get.pimoroni.com scripts! +Many scripts are based heavily on get.pimoroni.com scripts! - * Install i2s amplifier with: curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash \ No newline at end of file + * Install i2s amplifier with: curl -sS https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/i2samp.sh | bash + +## Python Scripts + +We are in the process of converting our Shell Scripts to Python. Instructions for running specific scripts are available in the [Adafruit Learning System](https://learn.adafruit.com/). Here are the general setup instructions. + +### Dependencies + +- Python 3 +- [Adafruit_Python_Shell](https://github.com/adafruit/Adafruit_Python_Shell) +- [Click](https://pypi.org/project/click/) + +### Prepare your system + +To install the dependencies for the python scripts, run the following commands: + +```bash +sudo apt-get install python3-pip click +sudo pip3 install --upgrade setuptools +sudo pip3 install --upgrade adafruit-python-shell +``` +Then to run the python script, type the following replacing "scriptname.py" with the actual script name: + +```bash +sudo python3 scriptname.py +``` + +## Old Shell Scripts + +If you were directed here from an external site and the script you were looking for appears to be missing, you can either use the newer python script or check the [converted_shell_scripts](https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/tree/main/converted_shell_scripts) folder to use the old shell scripts. \ No newline at end of file diff --git a/joy-bonnet.sh b/converted_shell_scripts/joy-bonnet.sh similarity index 100% rename from joy-bonnet.sh rename to converted_shell_scripts/joy-bonnet.sh diff --git a/libgpiod.sh b/converted_shell_scripts/libgpiod.sh similarity index 100% rename from libgpiod.sh rename to converted_shell_scripts/libgpiod.sh diff --git a/rpi-pin-kernel-firmware.sh b/converted_shell_scripts/rpi-pin-kernel-firmware.sh similarity index 100% rename from rpi-pin-kernel-firmware.sh rename to converted_shell_scripts/rpi-pin-kernel-firmware.sh diff --git a/raspi-blinka.py b/raspi-blinka.py index 9c117af..f63b65a 100644 --- a/raspi-blinka.py +++ b/raspi-blinka.py @@ -7,12 +7,11 @@ try: from adafruit_shell import Shell except ImportError: raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") -import os shell = Shell() shell.group="Blinka" default_python = 3 -blinka_minimum_python_version = 3.6 +blinka_minimum_python_version = 3.7 def default_python_version(numeric=True): version = shell.run_command("python -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True) diff --git a/rpi_pin_kernel_firmware.py b/rpi_pin_kernel_firmware.py index 43935b8..e7676ae 100644 --- a/rpi_pin_kernel_firmware.py +++ b/rpi_pin_kernel_firmware.py @@ -7,7 +7,6 @@ try: from adafruit_shell import Shell except ImportError: raise RuntimeError("The library 'adafruit_shell' was not found. To install, try typing: sudo pip3 install adafruit-python-shell") -import os shell = Shell() shell.group = 'PINNING' @@ -39,19 +38,18 @@ def main(): ] new_packages = [] for package in packagelist: - filename = "{}_{}_armhf.deb".format(package, version) + filename = f"{package}_{version}_armhf.deb" new_packages.append(filename) shell.run_command("wget --continue -O {} {}".format(filename, base + filename)) shell.run_command("dpkg -i " + " ".join(new_packages)) for package in packagelist: - write_text_file("/etc/apt/preferences.d/99-adafruit-pin-kernel", -"""Package: {} -Pin: version {} -Pin-Priority:999 - -""".format(package, version)) + shell.write_text_file("/etc/apt/preferences.d/99-adafruit-pin-kernel", ( + f"Package: {package}\n" + f"Pin: version {version}\n" + f"Pin-Priority:999\n\n" + )) shell.prompt_reboot() # Main function