Commit 80071eb9 by Scott Duckworth

treat KeyInfo as object not tuple

parent c14af483
......@@ -75,17 +75,18 @@ class UserKey(models.Model):
def clean(self):
try:
type, b64key, comment, self.fingerprint = key_parse(self.key)
if comment:
self.key = "%s %s %s" % (type.decode(), b64key.decode(), comment)
info = key_parse(self.key)
self.fingerprint = info.fingerprint
if info.comment:
self.key = "%s %s %s" % (info.type.decode(), info.b64key.decode(), info.comment)
else:
self.key = "%s %s" % (type.decode(), b64key.decode())
self.key = "%s %s" % (info.type.decode(), info.b64key.decode())
except SSHKeyFormatError as e:
raise ValidationError(str(e))
if not self.name:
if not comment:
if not info.comment:
raise ValidationError('Name or key comment required')
self.name = comment
self.name = info.comment
def validate_unique(self, exclude=None):
if self.pk is None:
......
......@@ -146,7 +146,8 @@ def lookup_by_fingerprint_main():
)
sys.exit(1)
try:
type, b64key, comment, fingerprint = key_parse(key)
info = key_parse(key)
fingerprint = info.fingerprint
except SSHKeyFormatError as e:
sys.stderr.write("Error: " + str(e))
sys.exit(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment