pmb.install._install: check sdcard exist (extra sanity check) (!1894)

This commit is contained in:
Antoine Fontaine 2020-03-22 11:09:04 +01:00 committed by Oliver Smith
parent 00dc54a6c7
commit 350d384492
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 2 additions and 0 deletions

View File

@ -362,6 +362,8 @@ def embed_firmware(args):
def sanity_check_sdcard(device):
device_name = os.path.basename(device)
if not os.path.exists(device):
raise RuntimeError("{} doesn't exist, is the sdcard plugged?".format(device))
if os.path.isdir('/sys/class/block/{}'.format(device_name)):
with open('/sys/class/block/{}/ro'.format(device_name), 'r') as handle:
ro = handle.read()