diff --git a/_version.py b/_version.py index bd75d1a..908c886 100644 --- a/_version.py +++ b/_version.py @@ -1 +1 @@ -__version__ = "amber-kenya-0.0.1" \ No newline at end of file +__version__ = "ami-ble-0.0.4" diff --git a/amitrap.py b/amitrap.py index b7ca2dc..dfdd516 100644 --- a/amitrap.py +++ b/amitrap.py @@ -211,15 +211,23 @@ def get_memory_info(self): def _is_ssd_connected(self): """ - Checks if a drive is connected. + Checks if an SSD is connected and mounted at /media/pi/PiImages. Returns: - bool: True if at least one drive is connected, False otherwise. + bool: True if /dev/sda is connected and mounted at /media/pi/PiImages, False otherwise. """ - output = subprocess.check_output(['lsblk', '-o', 'NAME,TYPE']) - # Decode the output from bytes to string - output = output.decode('utf-8') - return "sda" in output + try: + # Check if /dev/sda is mounted at /media/pi/PiImages + output = subprocess.check_output(['lsblk', '-o', 'NAME,MOUNTPOINT'], text=True) + + for line in output.splitlines(): + if "sda" in line and "/media/pi/PiImages" in line: + return True + + return False + + except subprocess.CalledProcessError: + return False def get_bluetooth_info(self): """ @@ -356,9 +364,20 @@ def set_time(self, time=None, zone=None): subprocess.run(bash_cmd, check=True, shell=True, timeout=2) except Exception as e: print(e) - print("Could not set RTC time. Is there an issue with the WittyPi?") + print("Could not set RTC time. Is there an issue with the WittyPi? Ignore if you are not using a WittyPi.") print() + try: + # Set system time from RTC + bash_cmd = f"sudo hwclock -w" + print(bash_cmd) + print() + subprocess.run(bash_cmd, check=True, shell=True, timeout=2) + except Exception as e: + print(e) + print("Could not set RTC time. Is there an issue with the DS3231? Ignore if you are not using a DS3231.") + print() + def get_serial_number(self): """ Gets the serial number of the Raspberry Pi / Rock Pi. diff --git a/install.sh b/install.sh index 3a0c6e0..28ba8af 100644 --- a/install.sh +++ b/install.sh @@ -1 +1 @@ -cp -r "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/* "/home/pi/ami_setup-bluetooth-dev" \ No newline at end of file +cp -r "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/* "/home/pi/ami_setup"