Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools/pamusb-conf: tighten --add-device logic #30

Merged
merged 1 commit into from
Apr 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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