Skip to content

Commit

Permalink
Merge pull request #30 from cdituri/tighter--add-device-logic
Browse files Browse the repository at this point in the history
tools/pamusb-conf: tighten --add-device logic
  • Loading branch information
aluzzardi committed Apr 27, 2016
2 parents b96b4f7 + 537d85c commit 40b17fa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/pamusb-conf
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,16 @@ def addDevice(options):
sys.exit(1)

devs = doc.getElementsByTagName('devices')

# Check that the id of the device to add is not already present in the configFile
for devices in devs:
for device in devices.getElementsByTagName("device"):
if device.getAttribute("id") == options['deviceName']:
msg = [ '\nWARNING: A device node already exits for new device \'%s\'.',
'\nTo proceed re-run --add-device using a different name or remove the existing entry in %s.' ]
print '\n'.join(msg) % (options['deviceName'], options['configFile'])
sys.exit(2)

dev = doc.createElement('device')
dev.attributes['id'] = options['deviceName']

Expand Down

0 comments on commit 40b17fa

Please sign in to comment.