Skip to content

Commit

Permalink
Add --get-snapshot to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
kk7ds committed Feb 14, 2016
1 parent 55d989b commit 8b96a71
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions uvcclient/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import logging
import optparse
import sys

from uvcclient import nvr
from uvcclient import camera
Expand All @@ -29,6 +30,14 @@ def do_led(camera_info, enabled):
cam_client.set_led(enabled)


def do_snapshot(camera_info):
cam_client = camera.UVCCameraClient(camera_info['host'],
camera_info['username'],
'ubnt') # FIXME
cam_client.login()
return cam_client.get_snapshot()


def main():
host, port, apikey, path = nvr.get_auth_from_env()

Expand Down Expand Up @@ -57,6 +66,8 @@ def main():
'returned from --get-picture-settings'))
parser.add_option('--set-led', default=None, metavar='ENABLED',
help='Enable/Disable front LED (on,off)')
parser.add_option('--get-snapshot', default=None, action='store_true',
help='Get a snapshot image and write to stdout')
parser.add_option('--prune-zones', default=None, action='store_true',
help='Prune all but the first motion zone')
parser.add_option('--list-zones', default=None, action='store_true',
Expand Down Expand Up @@ -152,3 +163,9 @@ def main():
zones = client.list_zones(opts.uuid)
for zone in zones:
print(zone['name'])
elif opts.get_snapshot:
camera = client.get_camera(opts.uuid)
if not camera:
print('No such camera')
return 1
sys.stdout.buffer.write(do_snapshot(camera))

0 comments on commit 8b96a71

Please # to comment.