Skip to content

Commit

Permalink
Add support for a "help" action that prints the driver module's docst…
Browse files Browse the repository at this point in the history
…ring.

This allows the drivers to provide information on what they support
directly, rather than relying on the README file. It also allows to provide
further information for the quirkier devices.

This is again trying to resolve Issue #9.
  • Loading branch information
Flameeyes committed Apr 17, 2017
1 parent 2a825fb commit 5ef9873
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions glucometer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import argparse
import importlib
import inspect
import logging
import sys

Expand All @@ -34,6 +35,9 @@ def main():
help=('Python logging level. See the levels at '
'https://docs.python.org/3/library/logging.html#logging-levels'))

subparsers.add_parser(
'help', help=('Display a description of the driver, including supported '
'features and known quirks.'))
subparsers.add_parser(
'info', help='Display information about the meter.')
subparsers.add_parser(
Expand Down Expand Up @@ -67,6 +71,12 @@ def main():
args.driver)
return 1

# This check needs to happen before we try to initialize the device, as the
# help action does not require a --device at all.
if args.action == 'help':
print(inspect.getdoc(driver))
return 0

device = driver.Device(args.device)

device.connect()
Expand Down
15 changes: 14 additions & 1 deletion glucometerutils/drivers/sdcodefree.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# -*- coding: utf-8 -*-
"""Driver for SD CodeFree devices by SD Biosensor"""
"""Driver for SD CodeFree devices by SD Biosensor.
For SD Biosensor glucometers using the serial interface.
Supported features:
- get readings, including pre-/post-meal notes;
- set date and time.
Expected device path: /dev/ttyUSB0 or similar serial port device.
IMPORTANT NOTE: the glucometer can be connected before starting the program, but
it has to be turned on when the program asks you to.
"""


__author__ = 'Diego Elio Pettenò'
__email__ = 'flameeyes@flameeyes.eu'
Expand Down

0 comments on commit 5ef9873

Please sign in to comment.