From 6cdfa96267c2c8442d0bb9b2d06cd5546e36c6a0 Mon Sep 17 00:00:00 2001 From: SIN admins Date: Tue, 28 Jul 2020 21:29:43 +0100 Subject: [PATCH] sms_functions: improved PIN input handling --- sms_functions.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sms_functions.py b/sms_functions.py index f6fe687..90d2b24 100644 --- a/sms_functions.py +++ b/sms_functions.py @@ -62,11 +62,12 @@ def unlock_sim(modem): logger.info("Trying to unlock %s", sim_path) with SystemBus() as bus: sim = bus.get('.ModemManager1', sim_path) - sim.SendPin(mypin, timeout=10000) - props = modem.GetStatus() - if props and props['state'] == 2: + try: + sim.SendPin(mypin, timeout=10000) + except GLib.Error as exc: remaining_attempts = modem.UnlockRetries - raise SIMError('Wrong PIN! Remaining attempts: {}'.format(remaining_attempts)) + raise SIMError('Failed to unlock PIN, remaining attempts: {}'.format(remaining_attempts)) from exc + def send_sms(recipients, smsstring):