This repository has been archived on 2025-06-01. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
compLIB/compLib/__init__.py
Konstantin Lampalzer aac99a11ba Minor fixes
2021-09-11 21:12:58 +02:00

41 lines
1.4 KiB
Python

__version__ = "0.1.5-1"
import importlib
import compLib.LogstashLogging
import compLib.MetricsLogging
apt_found = importlib.util.find_spec("apt") is not None
spi_found = importlib.util.find_spec("spidev") is not None
if apt_found:
import apt
try:
__versions = apt.Cache()["python3-complib"].versions
if len(__versions) != 1:
print(f"Starting compLib! \033[91mVersion: {__version__} is outdated\033[0m\n"
f"\033[92m[!] run the command 'sudo apt update && sudo apt install python3-complib' to install the newest version\033[0m")
else:
print(f"Starting compLib! \033[92mVersion: {__version__} is up to date\033[0m")
except Exception as e:
compLib.LogstashLogging.Logging.get_logger().error(f"error during checking apt package version -> {str(e)}")
print(f"\033[91merror during checking apt package version -> {str(e)}\033[0m\n")
else:
print("apt is not installed! This is for local development only!")
if spi_found:
import compLib.Spi
import compLib.Reset
import compLib.Encoder
import logging
print(f"\033[34mInitializing chipmunk board...\033[0m")
compLib.Reset.Reset.reset_bot()
compLib.Spi.Spi.health_check()
compLib.Spi.Spi.start_health_check_loop()
compLib.Encoder.Encoder.clear_all()
print(f"\033[34mReady\033[0m\n")
else:
print("spidev is not installed! This is for local development only!")