2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 03:19:48 +00:00

More cleanly error on unknown media

Rather than raise ugly unexpected
errors and pollute trace log,
cleanly handle the likelihood
of unknown media.
This commit is contained in:
Jarrod Johnson 2020-06-18 11:11:53 -04:00
parent 1c579723cc
commit d40426ff54
2 changed files with 5 additions and 1 deletions

View File

@ -184,7 +184,8 @@ def osimport(imagefile):
else:
print(repr(rsp))
time.sleep(0.5)
list(c.delete('/deployment/importing/{0}'.format(shortname)))
if shortname:
list(c.delete('/deployment/importing/{0}'.format(shortname)))
if __name__ == '__main__':
main(sys.argv)

View File

@ -1,4 +1,5 @@
#!/usr/bin/python
import confluent.exceptions as exc
import confluent.messages as msg
import eventlet
import eventlet.green.select as select
@ -428,6 +429,8 @@ class MediaImporter(object):
self.worker = None
self.profiles = []
identity = fingerprint(media)
if not identity:
raise exc.InvalidArgumentException('Unsupported Media')
self.percent = 0.0
identity, _ = identity
self.phase = 'copying'