From a6b52d5a9dbcdaf2d16408a39294582b327ba905 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Fri, 5 Feb 2016 17:14:35 -0800 Subject: [PATCH] Fix cookie name on py3 and add get_snapshot() to camera interface --- uvcclient/camera.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/uvcclient/camera.py b/uvcclient/camera.py index cc773ac..c024348 100644 --- a/uvcclient/camera.py +++ b/uvcclient/camera.py @@ -41,7 +41,7 @@ def login(self): conn.request('GET', '/') resp = conn.getresponse() headers = dict(resp.getheaders()) - self._cookie = headers['set-cookie'] + self._cookie = headers['Set-Cookie'] session = self._cookie.split('=')[1].split(';')[0] try: @@ -74,3 +74,10 @@ def _cfgwrite(self, setting, value): def set_led(self, enabled): return self._cfgwrite('led.front.status', int(enabled)) + + def get_snapshot(self): + conn = httplib.HTTPConnection(self._host, self._port) + headers = {'Cookie': self._cookie} + conn.request('GET', '/snapshot.cgi', + headers=headers) + return conn.getresponse().read()