From c5d7e5c8a8175111f41fe00ea651092cca405459 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Wed, 21 Mar 2007 00:28:53 +0000 Subject: [PATCH] pamusb-conf: Avoid to ask a question if there's only one possible response (only one device detected, etc) --- pam_usb/tools/pamusb-conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pam_usb/tools/pamusb-conf b/pam_usb/tools/pamusb-conf index 405206f..d719641 100755 --- a/pam_usb/tools/pamusb-conf +++ b/pam_usb/tools/pamusb-conf @@ -62,7 +62,11 @@ class Device: def listOptions(question, options, autodetect = True): if autodetect == True and len(options) == 1: + print question + print "* Using \"%s\" (only option)" % options[0] + print return 0 + while True: try: print question @@ -103,7 +107,6 @@ def prettifyElement(element): return tmp.lastChild def addUser(options): - print 'adding user %s' % options['userName'] try: doc = minidom.parse(options['configFile']) except Exception, err: @@ -122,9 +125,8 @@ def addUser(options): devices = [] for device in devicesObj: devices.append(device.getAttribute('id')) - print devices device = devices[listOptions("Which device would you like to use for authentication ?", - devices, False)] + devices)] shouldSave(options, [ ('User', options['userName']), @@ -159,21 +161,19 @@ def addDevice(options): volume = volumes[listOptions("Which volume would you like to use for " \ "storing data ?", ["%s (UUID: %s)" % (volume['device'], - volume['uuid']) + volume['uuid'] or "") for volume in volumes] )] - uuid = volume['uuid'] if volume['uuid'] == '': print 'WARNING: No UUID detected for device %s. One time pads will be disabled.' % volume['device'] - uuid = "" shouldSave(options,[ ('Name', options['deviceName']), ('Vendor', device.vendor), ('Model', device.product), ('Serial', device.serialNumber), - ('UUID', uuid) + ('UUID', volume['uuid'] or "") ]) try: