Skip to content

Commit

Permalink
Add online/offline state to listing
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Nov 17, 2015
1 parent c5ffd20 commit 49c5f69
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions uvcclient/uvcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def index(self):
"""
cams = self._uvc_request('/api/2.0/camera')['data']
return [{'name': x['name'],
'uuid': x['uuid']} for x in cams]
'uuid': x['uuid'],
'state': x['state'],
} for x in cams]

def name_to_uuid(self, name):
"""Attempt to convert a camera name to its UUID.
Expand Down Expand Up @@ -220,7 +222,13 @@ def main():
client.dump(opts.uuid)
elif opts.list:
for cam in client.index():
print('%s: %s' % (cam['uuid'], cam['name']))
if cam['state'] == 'DISCONNECTED':
status = 'offline'
elif cam['state'] == 'CONNECTED':
status = 'online'
else:
status = 'unknown:%s' % cam['state']
print('%s: %-24.24s [%10s]' % (cam['uuid'], cam['name'], status))
elif opts.recordmode:
r = client.set_recordmode(opts.uuid, opts.recordmode,
opts.recordchannel)
Expand Down

0 comments on commit 49c5f69

Please sign in to comment.