Skip to content

Commit

Permalink
Fall back to getting the image through the NVR if direct fails
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Feb 23, 2016
1 parent eff01b8 commit c14daaf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions uvcclient/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ def do_led(camera_info, enabled):
cam_client.set_led(enabled)


def do_snapshot(camera_info):
def do_snapshot(client, camera_info):
password = INFO_STORE.get_camera_password(camera_info['uuid']) or 'ubnt'
cam_client = camera.UVCCameraClient(camera_info['host'],
camera_info['username'],
password)
cam_client.login()
return cam_client.get_snapshot()
try:
cam_client.login()
return cam_client.get_snapshot()
except (camera.CameraAuthError, camera.CameraConnectError):
# Fall back to proxy through the NVR
return client.get_snapshot(camera_info['uuid'])


def do_set_password(opts):
Expand Down Expand Up @@ -191,7 +195,7 @@ def main():
print('No such camera')
return 1
if hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer.write(do_snapshot(camera))
sys.stdout.buffer.write(do_snapshot(client, camera))
else:
sys.stdout.write(do_snapshot(camera))
elif opts.set_password:
Expand Down

0 comments on commit c14daaf

Please sign in to comment.