'Decorator which automatically selects a device transport before calling
the decorated function, and closes the connection afterward.'

def _with_transport(fn):

    @functools.wraps(fn)
    def wrapper(self, *a, **kw):
        self.transport()
        rv = fn(self, *a, **kw)
        if self._c:
            self._c.close()
            self._c = None
        return rv
    return wrapper
