Browse Source

pamusb-conf: Avoid to ask a question if there's only one possible

response (only one device detected, etc)
master
Andrea Luzzardi 18 years ago
parent
commit
c5d7e5c8a8
1 changed files with 7 additions and 7 deletions
  1. +7
    -7
      pam_usb/tools/pamusb-conf

+ 7
- 7
pam_usb/tools/pamusb-conf View File

@ -62,7 +62,11 @@ class Device:
def listOptions(question, options, autodetect = True): def listOptions(question, options, autodetect = True):
if autodetect == True and len(options) == 1: if autodetect == True and len(options) == 1:
print question
print "* Using \"%s\" (only option)" % options[0]
print
return 0 return 0
while True: while True:
try: try:
print question print question
@ -103,7 +107,6 @@ def prettifyElement(element):
return tmp.lastChild return tmp.lastChild
def addUser(options): def addUser(options):
print 'adding user %s' % options['userName']
try: try:
doc = minidom.parse(options['configFile']) doc = minidom.parse(options['configFile'])
except Exception, err: except Exception, err:
@ -122,9 +125,8 @@ def addUser(options):
devices = [] devices = []
for device in devicesObj: for device in devicesObj:
devices.append(device.getAttribute('id')) devices.append(device.getAttribute('id'))
print devices
device = devices[listOptions("Which device would you like to use for authentication ?", device = devices[listOptions("Which device would you like to use for authentication ?",
devices, False)]
devices)]
shouldSave(options, [ shouldSave(options, [
('User', options['userName']), ('User', options['userName']),
@ -159,21 +161,19 @@ def addDevice(options):
volume = volumes[listOptions("Which volume would you like to use for " \ volume = volumes[listOptions("Which volume would you like to use for " \
"storing data ?", "storing data ?",
["%s (UUID: %s)" % (volume['device'], ["%s (UUID: %s)" % (volume['device'],
volume['uuid'])
volume['uuid'] or "<UNDEFINED>")
for volume in volumes] for volume in volumes]
)] )]
uuid = volume['uuid']
if volume['uuid'] == '': if volume['uuid'] == '':
print 'WARNING: No UUID detected for device %s. One time pads will be disabled.' % volume['device'] print 'WARNING: No UUID detected for device %s. One time pads will be disabled.' % volume['device']
uuid = "<UNDEFINED>"
shouldSave(options,[ shouldSave(options,[
('Name', options['deviceName']), ('Name', options['deviceName']),
('Vendor', device.vendor), ('Vendor', device.vendor),
('Model', device.product), ('Model', device.product),
('Serial', device.serialNumber), ('Serial', device.serialNumber),
('UUID', uuid)
('UUID', volume['uuid'] or "<UNDEFINED>")
]) ])
try: try:


Loading…
Cancel
Save