From 032cd0cf3b58dcbb80d066c5409ea15c2af258ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 15 Apr 2017 15:08:33 +0100 Subject: all drivers: make --device optional at the tool level. This requires the drivers to validate their device, but also means they can provide a more explicit error message for the user as to what should be passed. This is a first step to help solving Issue 9. --- glucometerutils/drivers/fsoptium.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'glucometerutils/drivers/fsoptium.py') diff --git a/glucometerutils/drivers/fsoptium.py b/glucometerutils/drivers/fsoptium.py index fd4c791..92ee76d 100644 --- a/glucometerutils/drivers/fsoptium.py +++ b/glucometerutils/drivers/fsoptium.py @@ -79,6 +79,11 @@ def _parse_clock(datestr): class Device(object): def __init__(self, device): + if not device: + raise exceptions.CommandLineError( + '--device parameter is required, should point to the serial device ' + 'connected to the meter.') + self.serial_ = serial.Serial( port=device, baudrate=19200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, -- cgit v1.2.3