How to use the ckanapi.errors function in ckanapi

To help you get started, we’ve selected a few ckanapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ADEQUATeDQ / portalmonitor / odpw / core / portal_fetch_processors.py View on Github external
def _get_datasets(self, api, timeout_attempts, rows, start, portal_id):
        for attempt in xrange(timeout_attempts):
            time.sleep(self._waiting_time(attempt))
            try:
                response = api.action.package_search(rows=rows, start=start)
                return response
            except ckanapi.errors.CKANAPIError as e:
                err = literal_eval(e.extra_msg)
                if 500 <= err[1] < 600:
                    rows =rows/3 if rows>=3 else rows
                    log.warn("CKANPackageSearchFetch", pid=portal_id, error='Internal Server Error. Retrying after waiting time.', errorCode=str(err[1]), attempt=attempt, waiting=self._waiting_time(attempt), rows=rows)
                else:
                    raise e
        raise e
github ADEQUATeDQ / portalmonitor / odpw / utils / error_handling.py View on Github external
#connection erorrs
    try:

        if isinstance(e,requests.exceptions.ConnectionError):
            return 702
        if isinstance(e,requests.exceptions.ConnectTimeout):
            return 703
        if isinstance(e,requests.exceptions.ReadTimeout):
            return 704
        if isinstance(e,requests.exceptions.HTTPError):
            return 705
        if isinstance(e,requests.exceptions.TooManyRedirects):
            return 706
        if isinstance(e,requests.exceptions.Timeout):
            return 707
        if isinstance(e,ckanapi.errors.CKANAPIError):
            try:
                err = literal_eval(e.extra_msg)
                return err[1]
            except Exception:
                return 708

        #if isinstance(e,requests.exceptions.RetryError):
        #    return 708

        #parser errors
        if isinstance(e, exceptions.ValueError):
            return 801
        if isinstance(e , TimeoutError):
            return 802
        #format errors
        if isinstance(e,urlnorm.InvalidUrl):
github ADEQUATeDQ / portalmonitor / odpw / utils / util.py View on Github external
def getExceptionString(e):
    try:
        if isinstance(e,ckanapi.errors.CKANAPIError):
            try:
                err = literal_eval(e.extra_msg)
                return str(type(e))+":"+str(err[2])
            except Exception:
                return str(type(e))+":"+str(e.extra_msg)
        else:
            return str(type(e))+":"+str(e.message)
    except Exception as e:
        log.error("Get Exception string", exctype=type(e), excmsg=e.message,exc_info=True)
        return 601
github ADEQUATeDQ / portalmonitor / odpw / portal_processor.py View on Github external
def _get_datasets(self, api, timeout_attempts, rows, start, portal_id):
        #using timeout_attempts attempts

        for attempt in xrange(timeout_attempts):
            time.sleep(self._waiting_time(attempt))
            try:
                response = api.action.package_search(rows=rows, start=start)
                return response
            except ckanapi.errors.CKANAPIError as e:
                err = literal_eval(e.extra_msg)
                if 500 <= err[1] < 600:
                    rows =rows/3 if rows>=3 else rows
                    log.warn("CKANPackageSearchFetch", pid=portal_id, error='Internal Server Error. Retrying after waiting time.', errorCode=str(err[1]), attempt=attempt, waiting=self._waiting_time(attempt), rows=rows)
                else:
                    raise e
        raise e
github ADEQUATeDQ / portalmonitor / odpw / utils / error_handling.py View on Github external
def getExceptionString(e):
    try:
        if isinstance(e,ckanapi.errors.CKANAPIError):
            try:
                err = literal_eval(e.extra_msg)
                return str(type(e))+":"+str(err[2])
            except Exception:
                return str(type(e))+":"+str(e.extra_msg)
        else:
            if e.message:
                return str(type(e))+":"+str(e.message)
            if e.message:
                return str(type(e))+":"
    except Exception as e:
        log.error("Get Exception string", exctype=type(e), excmsg=e.message,exc_info=True)
        return 601