# Path: pyDAPLink/errors.py
# class CommandError(ValueError):
#     pass


from ..errors import CommandError
import client
import logging
        if self._new_socket:
            self._client.uninit()


    def _command(self, *args):
        """ Defers command handling to client class. """
        return self._client.command(*args)

    @property
    def locked(self):
        return self._nested_locks > 0

    def lock(self):
        """ Locks device for exclusive access from this connection. """
        self._nested_locks += 1
        if self._nested_locks > 1:
            return

        attempts = 0

        while (not self._lock_attempts or attempts < self._lock_attempts):
            try:
                data = self._command('board_select', {'id': self.iid})

                if data['selected']:
                    return
                else:
                    attempts += 1
            except ServerError as err:
                if err.type == 'KeyError':

# Path: pyDAPLink/errors.py
# class CommandError(ValueError):
#     pass


# Path: pyDAPLink/client/transport.py
from ..errors import CommandError
import client
import logging

        if self._new_socket:
            self._client.uninit()


    def _command(self, *args):
        """ Defers command handling to client class. """
        return self._client.command(*args)

    @property
    def locked(self):
        return self._nested_locks > 0

    def lock(self):
        """ Locks device for exclusive access from this connection. """
        self._nested_locks += 1
        if self._nested_locks > 1:
            return

        attempts = 0

        while (not self._lock_attempts or attempts < self._lock_attempts):
            try:
                data = self._command('board_select', {'id': self.iid})

                if data['selected']:
                    return
                else:
                    attempts += 1
            except ServerError as err:
                if err.type == 'KeyError':

                    raise CommandError('Unable to select device %04x:%04x:%x' % 