コード例 #1
0
ファイル: async.py プロジェクト: dancollins34/python-arango
 def handler(res):
     if res.status_code in HTTP_OK:
         return True
     elif res.status_code == 404:
         if ignore_missing:
             return False
         raise AsyncJobClearError(res, 'Job {} missing'.format(self.id))
     else:
         raise AsyncJobClearError(res)
コード例 #2
0
ファイル: async.py プロジェクト: ddparker/python-arango
    def clear(self, ignore_missing=False):
        """Delete the result of the job from the server.

        :param ignore_missing: ignore missing async jobs
        :type ignore_missing: bool
        :returns: ``True`` if the result was deleted successfully, ``False``
            if the job was not found but **ignore_missing** was set to ``True``
        :rtype: bool
        :raises arango.exceptions.AsyncJobClearError: if the result of the
            async job cannot be delete from the server
        """
        res = self._conn.delete('/_api/job/{}'.format(self._id))
        if res.status_code in HTTP_OK:
            return True
        elif res.status_code == 404:
            if ignore_missing:
                return False
            raise AsyncJobClearError(res, 'Job {} missing'.format(self._id))
        else:
            raise AsyncJobClearError(res)
コード例 #3
0
    def clear(self, ignore_missing=False):
        """Delete the job result from the server.

        :param ignore_missing: Do not raise an exception on missing job.
        :type ignore_missing: bool
        :return: True if result was deleted successfully, False if the job
            was not found but **ignore_missing** was set to True.
        :rtype: bool
        :raise arango.exceptions.AsyncJobClearError: If delete fails.
        """
        request = Request(method='delete',
                          endpoint='/_api/job/{}'.format(self._id))
        resp = self._conn.send_request(request)
        if resp.is_success:
            return True
        elif resp.error_code == 404:
            if ignore_missing:
                return False
            error_message = 'job {} not found'.format(self._id)
            raise AsyncJobClearError(resp, request, error_message)
        else:
            raise AsyncJobClearError(resp, request)