diff --git a/adafruit-pitft-mipi.py b/adafruit-pitft-mipi.py index f199e02..e364efa 100755 --- a/adafruit-pitft-mipi.py +++ b/adafruit-pitft-mipi.py @@ -246,9 +246,9 @@ def sysupdate(): if not UPDATE_DB: print("Updating apt indexes...", end='') progress(3) - if not shell.run_command('sudo apt update', True): + if not shell.run_command('sudo apt update', suppress_message=True): warn_exit("Apt failed to update indexes!") - if not shell.run_command('sudo apt-get update', True): + if not shell.run_command('sudo apt-get update', suppress_message=True): warn_exit("Apt failed to update indexes!") print("Reading package lists...") progress(3) @@ -259,7 +259,7 @@ def sysupdate(): def softwareinstall(): print("Installing Pre-requisite Software...This may take a few minutes!") - if not shell.run_command("apt-get install -y libts0", True): + if not shell.run_command("apt-get install -y libts0", suppress_message=True): if not shell.run_command("apt-get install -y tslib"): if not shell.run_command("apt-get install -y libts-dev"): warn_exit("Apt failed to install TSLIB!") @@ -489,7 +489,7 @@ restart the script and choose a different orientation.""".format(rotation=pitftr # check init system (technique borrowed from raspi-config): shell.info('Checking init system...') - if shell.run_command("which systemctl", True) and shell.run_command("systemctl | grep '\-\.mount'", True): + if shell.run_command("which systemctl", suppress_message=True) and shell.run_command("systemctl | grep '\-\.mount'", suppress_message=True): SYSTEMD = True print("Found systemd") elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"): diff --git a/adafruit-pitft.py b/adafruit-pitft.py index 1d0383f..d8f8493 100755 --- a/adafruit-pitft.py +++ b/adafruit-pitft.py @@ -223,9 +223,9 @@ def sysupdate(): if not UPDATE_DB: print("Updating apt indexes...", end='') progress(3) - if not shell.run_command('sudo apt update', True): + if not shell.run_command('sudo apt update', suppress_message=True): warn_exit("Apt failed to update indexes! Try running 'sudo apt update' manually.") - if not shell.run_command('sudo apt-get update', True): + if not shell.run_command('sudo apt-get update', suppress_message=True): warn_exit("Apt failed to update indexes! Try running 'sudo apt-get update' manually.") print("Reading package lists...") progress(3) @@ -236,7 +236,7 @@ def sysupdate(): def softwareinstall(): print("Installing Pre-requisite Software...This may take a few minutes!") - if not shell.run_command("apt-get install -y libts0", True): + if not shell.run_command("apt-get install -y libts0", suppress_message=True): if not shell.run_command("apt-get install -y tslib"): if not shell.run_command("apt-get install -y libts-dev"): warn_exit("Apt failed to install TSLIB!") @@ -282,13 +282,13 @@ def install_drivers(): if is_kernel_upgrade_required(): print("############# UPGRADING KERNEL ###############") print("Updating packages...") - if not shell.run_command("sudo apt-get update", True): + if not shell.run_command("sudo apt-get update", suppress_message=True): warn_exit("Apt failed to update itself!") print("Upgrading packages...") - if not shell.run_command("sudo apt-get -y upgrade", False): + if not shell.run_command("sudo apt-get -y upgrade"): warn_exit("Apt failed to install software!") print("Installing Kernel Headers. This may take a few minutes...") - if not shell.run_command("apt-get install -y raspberrypi-kernel-headers", True): + if not shell.run_command("apt-get install -y raspberrypi-kernel-headers", suppress_message=True): warn_exit("Apt failed to install software!") # If the kernel was upgraded, a build folder should exist once it has been loaded module = pitft_config['kernel_module'] @@ -390,23 +390,23 @@ def uninstall_console(): def install_fbcp(): global fbcp_rotations print("Installing cmake...") - if not shell.run_command("apt-get --yes --allow-downgrades --allow-remove-essential --allow-change-held-packages install cmake", True): + if not shell.run_command("apt-get --yes --allow-downgrades --allow-remove-essential --allow-change-held-packages install cmake", suppress_message=True): warn_exit("Apt failed to install software!") print("Downloading rpi-fbcp...") shell.pushd("/tmp") shell.run_command("curl -sLO https://github.com/adafruit/rpi-fbcp/archive/master.zip") print("Uncompressing rpi-fbcp...") shell.run_command("rm -rf /tmp/rpi-fbcp-master") - if not shell.run_command("unzip master.zip", True): + if not shell.run_command("unzip master.zip", suppress_message=True): warn_exit("Failed to uncompress fbcp!") shell.chdir("rpi-fbcp-master") shell.run_command("mkdir build") shell.chdir("build") print("Building rpi-fbcp...") shell.write_text_file("../CMakeLists.txt", "\nset (CMAKE_C_FLAGS \"-std=gnu99 ${CMAKE_C_FLAGS}\")") - if not shell.run_command("cmake ..", True): + if not shell.run_command("cmake ..", suppress_message=True): warn_exit("Failed to cmake fbcp!") - if not shell.run_command("make", True): + if not shell.run_command("make", suppress_message=True): warn_exit("Failed to make fbcp!") print("Installing rpi-fbcp...") shell.run_command("install fbcp /usr/local/bin/fbcp") @@ -669,7 +669,7 @@ restart the script and choose a different orientation.""".format(rotation=pitftr # check init system (technique borrowed from raspi-config): shell.info('Checking init system...') - if shell.run_command("which systemctl", True) and shell.run_command("systemctl | grep '\-\.mount'", True): + if shell.run_command("which systemctl", suppress_message=True) and shell.run_command("systemctl | grep '\-\.mount'", suppress_message=True): SYSTEMD = True print("Found systemd") elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"): diff --git a/adafruit_fanservice.py b/adafruit_fanservice.py index 8403aef..f2d557b 100644 --- a/adafruit_fanservice.py +++ b/adafruit_fanservice.py @@ -47,7 +47,7 @@ Run time < 1 minute. Reboot not required.""") # check init system (technique borrowed from raspi-config): shell.group = 'FAN' shell.info('Checking init system...') - if shell.run_command("which systemctl", True) and shell.run_command("systemctl | grep '\-\.mount'", True): + if shell.run_command("which systemctl", suppress_message=True) and shell.run_command("systemctl | grep '\-\.mount'", suppress_message=True): print("Found systemd, OK!") elif os.path.isfile("/etc/init.d/cron") and not os.path.islink("/etc/init.d/cron"): shell.bail("Found sysvinit, but we require systemd") diff --git a/joy-bonnet.py b/joy-bonnet.py index accdfa3..9f2ad75 100755 --- a/joy-bonnet.py +++ b/joy-bonnet.py @@ -56,7 +56,7 @@ EXISTING INSTALLATION, IF ANY, WILL BE OVERWRITTEN. print(""" Starting installation... Updating package index files...""") - shell.run_command('sudo apt-get update', True) + shell.run_command('sudo apt-get update', suppress_message=True) print("Installing Python libraries...") shell.run_command('sudo apt-get install -y python3-pip python3-dev python3-smbus') diff --git a/raspi-blinka.py b/raspi-blinka.py index 013359c..5a5ec2f 100644 --- a/raspi-blinka.py +++ b/raspi-blinka.py @@ -5,6 +5,9 @@ Adafruit Raspberry Pi Blinka Setup Script Written by Melissa LeBlanc-Williams for Adafruit Industries """ +import os +import sys + try: from adafruit_shell import Shell except ImportError: @@ -82,11 +85,15 @@ def update_pip(): shell.run_command("sudo apt-get install -y python3-pip") shell.run_command("sudo pip3 install --upgrade setuptools") -def install_blinka(): +def install_blinka(user=False): print("Installing latest version of Blinka locally") shell.run_command("sudo apt-get install -y i2c-tools libgpiod-dev") - shell.run_command("pip3 install --upgrade RPi.GPIO") - shell.run_command("pip3 install --upgrade adafruit-blinka") + pip_command = "pip3 install --upgrade" + username = None + if user: + username = os.environ["SUDO_USER"] + shell.run_command(f"{pip_command} RPi.GPIO", run_as_user=username) + shell.run_command(f"{pip_command} adafruit-blinka", run_as_user=username) def main(): global default_python @@ -121,7 +128,7 @@ Raspberry Pi and installs Blinka set_raspiconfig() update_python() update_pip() - install_blinka() + install_blinka(True) # Done print("""DONE.