refine logic of do_open

parent bf6ef84a
......@@ -97,7 +97,11 @@ class OauTest(cmd.Cmd):
def do_open(self, arg):
"""open device by serial number."""
serial = self.devices[0]['serial'] if not arg else arg
try:
serial = self.devices[0]['serial'] if not arg else arg
except IndexError as e:
print('no devices found, cannot open')
return
fd = self.api.oau_att_open_by_serial(bytes(serial, 'utf8'))
if fd < 0:
print('cannot open device {}'.format(serial))
......
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 to comment