Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "amber-kenya-0.0.1"
__version__ = "ami-ble-0.0.4"
33 changes: 26 additions & 7 deletions amitrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cp -r "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/* "/home/pi/ami_setup-bluetooth-dev"
cp -r "$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"/* "/home/pi/ami_setup"