Made some requested changes

This commit is contained in:
Melissa LeBlanc-Williams 2020-08-14 10:46:26 -07:00
parent b7f04d58d7
commit 0cba038922
2 changed files with 38 additions and 51 deletions

16
.gitignore vendored Normal file
View file

@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: 2019 Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
*.mpy
.idea
__pycache__
_build
*.pyc
.env
build*
bundles
*.DS_Store
.eggs
dist
**/*.egg-info

View file

@ -1,49 +1,19 @@
from clint.textui import colored
import sys import sys
import os import os
import subprocess import subprocess
group = 'ADAFRUIT' group = 'ADAFRUIT'
class ColorPrint:
@staticmethod
def print_fail(message, system=None, end = '\n'):
if system is None:
system = group
sys.stdout.write('\x1b[1;31m\x1b[40m' + system.strip() + '\x1b[0m ' + message.strip() + end)
@staticmethod
def print_pass(message, system=None, end = '\n'):
if system is None:
system = group
sys.stdout.write('\x1b[1;32m\x1b[40m' + group.strip() + '\x1b[0m ' + message.strip() + end)
@staticmethod
def print_warn(message, system=None, end = '\n'):
if system is None:
system = group
sys.stdout.write('\x1b[1;33m\x1b[40m' + group.strip() + '\x1b[0m ' + message.strip() + end)
@staticmethod
def print_info(message, system=None, end = '\n'):
if system is None:
system = group
sys.stdout.write('\x1b[1;34m\x1b[40m' + group.strip() + '\x1b[0m ' + message.strip() + end)
@staticmethod
def print_bold(message, system=None, end = '\n'):
if system is None:
system = group
sys.stdout.write('\x1b[1;37m\x1b[40m' + group.strip() + '\x1b[0m ' + message.strip() + end)
def info(system, message): def info(system, message):
group = system group = system
ColorPrint.print_pass(message) print(colored.green(system) + " " + message)
def bail(message = None): def bail(message = None):
if message is None: if message is None:
ColorPrint.print_fail("Exiting due to error") print(colored.red(system) + " Exiting due to error")
else: else:
ColorPrint.print_fail("Exiting due to error: {message}".format(message=message)) print(colored.red(system) + " Exiting due to error: {}".format(message))
sys.exit(1) sys.exit(1)
def run_command(cmd, suppress_message = False): def run_command(cmd, suppress_message = False):
@ -56,27 +26,28 @@ def run_command(cmd, suppress_message = False):
return True return True
else: else:
if not suppress_message: if not suppress_message:
ColorPrint.print_fail(err.decode("utf-8")) print(colored.red(system) + " " + err.decode("utf-8"))
return False return False
def main(): def main():
os.system('clear') os.system('clear')
print("This script will install Adafruit") print("""This script will install Adafruit
print("fan service, which will turn on an") fan service, which will turn on an
print("external fan controlled by a given pin") external fan controlled by a given pin
print("")
print("Operations performed include:") Operations performed include:
print("- In /boot/config.txt, enable camera") - In /boot/config.txt, enable camera
print("- apt-get update") - apt-get update
print("- Install Python libraries:") - Install Python libraries:
print(" picamera, pygame, PIL") picamera, pygame, PIL
print("- Downgrade SDL library for pygame") - Downgrade SDL library for pygame
print(" touch compatibility") touch compatibility
print("- Download Dropbox Updater and") - Download Dropbox Updater and
print(" Adafruit Pi Cam software") Adafruit Pi Cam software
print("")
print("Run time 1+ minutes. Reboot not required.") Run time 1+ minutes. Reboot not required.
print("")
""")
if '-y' not in sys.argv: if '-y' not in sys.argv:
reply = input("CONTINUE? [y/N]") reply = input("CONTINUE? [y/N]")