From 0de4ea1cabde2c0333b806e8a21dcc67bd520a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 3 Aug 2013 09:56:57 +0100 Subject: glucometer: fix script to actually work and provide actions. --- glucometer.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/glucometer.py b/glucometer.py index 69748b4..a288dae 100644 --- a/glucometer.py +++ b/glucometer.py @@ -10,12 +10,12 @@ import argparse import importlib import sys -from glucometerutils import constants +from glucometerutils import common from glucometerutils.drivers import otultra2 def main(argv=sys.argv): parser = argparse.ArgumentParser() - subparsers = parser.add_subparsers() + subparsers = parser.add_subparsers(dest="action") parser.add_argument( '--driver', action='store', required=True, @@ -38,5 +38,16 @@ def main(argv=sys.argv): driver = importlib.import_module('glucometerutils.drivers.' + args.driver) device = driver.Device(args.device) + if args.action == 'dump': + for reading in device.GetReadings(): + print('%s,%f' % reading) + elif args.action == 'datetime': + if args.set: + print(device.SetDateTime()) + else: + print(device.GetDateTime()) + else: + return 1 + if __name__ == "__main__": main() -- cgit v1.2.3