How to use the census.core.CensusException function in census

To help you get started, we’ve selected a few census 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 datamade / census / census / View on Github external
                    raise ex

            headers = data.pop(0)
            types = [self._field_type(header, year) for header in headers]
            results = [{header : (cast(item) if item is not None else None)
                        for header, cast, item
                        in zip(headers, types, d)}
                       for d in data]
            return results

        elif resp.status_code == 204:
            return []

            raise CensusException(resp.text)
github datamade / census / census / View on Github external
def chunks(l, n):
    """Yield successive n-sized chunks from l."""
    for i in range(0, len(l), n):
        yield l[i:i + n]

def merge(dicts):
    return dict(item for d in dicts for item in d.items())

class CensusException(Exception):

class UnsupportedYearException(CensusException):

class Client(object):
    endpoint_url = ''
    definitions_url = ''
    definition_url = ''
    groups_url = ''

    def __init__(self, key, year=None, session=None, retries=3):
        self._key = key
        self.session = session or new_session()
        if year:
            self.default_year = year
        self.retries = retries
github datamade / census / census / View on Github external
def wrapper(self, *args, **kwargs):
        for _ in range(max(self.retries - 1, 0)):
                result = func(self, *args, **kwargs)
            except CensusException as e:
                if "There was an error while running your query.  We've logged the error and we'll correct it ASAP.  Sorry for the inconvenience." in str(e):
                return result
            return func(self, *args, **kwargs)