def get(self, id, pk='id', deleted=False):
        try:
            if pk == 'id':
                id = int(id)
            if deleted:
                spec = {pk: id}
            else:
                spec = {pk: id, 'data': {'$exists': 1}}
            fields = {'_id': 0}
            row = self.db.docs.find_one(spec, fields)
        except Exception as e:
            raise DatabaseException(e)
        if row:
            return Document(**row)
        raise NotFoundError('%s %s not found' % (pk, id))
def connectWithSsh(self):
        self._debugLog("Establishing connection to " + self.host)
        self._connection = self.pexpect.spawn(
                'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no %s@%s -p %d' % 
                (self._loginUser.username, self.host, self._port))
        if self._connection is None:
            raise Exception("Unable to connect via SSH perhaps wrong IP!")
        self._secure = True
        self._setupLog()
        self._loginUser.commandLine(self)
        self.modeList = [self._loginUser]