Exemple #1
0
    def _login(self):
        """Login to the camera."""
        from uvcclient import camera as uvc_camera
        from uvcclient import store as uvc_store

        caminfo = self._nvr.get_camera(self._uuid)
        if self._connect_addr:
            addrs = [self._connect_addr]
        else:
            addrs = [caminfo['host'], caminfo['internalHost']]

        store = uvc_store.get_info_store()
        password = store.get_camera_password(self._uuid)
        if password is None:
            _LOGGER.debug('Logging into camera %(name)s with default password',
                          dict(name=self._name))
            password = '******'

        if self._nvr.server_version >= (3, 2, 0):
            client_cls = uvc_camera.UVCCameraClientV320
        else:
            client_cls = uvc_camera.UVCCameraClient

        camera = None
        for addr in addrs:
            try:
                camera = client_cls(addr,
                                    caminfo['username'],
                                    password)
                camera.login()
                _LOGGER.debug('Logged into UVC camera %(name)s via %(addr)s',
                              dict(name=self._name, addr=addr))
                self._connect_addr = addr
                break
            except socket.error:
                pass
            except uvc_camera.CameraConnectError:
                pass
            except uvc_camera.CameraAuthError:
                pass
        if not self._connect_addr:
            _LOGGER.error('Unable to login to camera')
            return None

        self._camera = camera
        return True
Exemple #2
0
    def _login(self):
        """Login to the camera."""
        from uvcclient import camera as uvc_camera
        from uvcclient import store as uvc_store

        caminfo = self._nvr.get_camera(self._uuid)
        if self._connect_addr:
            addrs = [self._connect_addr]
        else:
            addrs = [caminfo['host'], caminfo['internalHost']]

        store = uvc_store.get_info_store()
        password = store.get_camera_password(self._uuid)
        if password is None:
            _LOGGER.debug('Logging into camera %(name)s with default password',
                          dict(name=self._name))
            password = '******'

        if self._nvr.server_version >= (3, 2, 0):
            client_cls = uvc_camera.UVCCameraClientV320
        else:
            client_cls = uvc_camera.UVCCameraClient

        camera = None
        for addr in addrs:
            try:
                camera = client_cls(addr,
                                    caminfo['username'],
                                    password)
                camera.login()
                _LOGGER.debug('Logged into UVC camera %(name)s via %(addr)s',
                              dict(name=self._name, addr=addr))
                self._connect_addr = addr
                break
            except socket.error:
                pass
            except uvc_camera.CameraConnectError:
                pass
            except uvc_camera.CameraAuthError:
                pass
        if not self._connect_addr:
            _LOGGER.error('Unable to login to camera')
            return None

        self._camera = camera
        return True
Exemple #3
0
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

import getpass
import logging
import optparse
import sys

from uvcclient import nvr
from uvcclient import camera
from uvcclient import store

INFO_STORE = store.get_info_store()


def do_led(camera_info, enabled):
    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()
    cam_client.set_led(enabled)


def do_snapshot(client, camera_info):
    password = INFO_STORE.get_camera_password(camera_info['uuid']) or 'ubnt'
    if client.server_version >= (3, 2, 0):
        cam_client = camera.UVCCameraClientV320(camera_info['host'],
                                                camera_info['username'],
Exemple #4
0
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

import getpass
import logging
import optparse
import sys

from uvcclient import nvr
from uvcclient import camera
from uvcclient import store

INFO_STORE = store.get_info_store()


def do_led(camera_info, enabled):
    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()
    cam_client.set_led(enabled)


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'],