django.db.transaction - python examples

Here are the examples of the python api django.db.transaction taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

0 View Complete Implementation : exception_handler.py
Copyright Apache License 2.0
Author : SubstraFoundation
def generate_exceptions_map(append=True):

    os.environ['DJANGO_SETTINGS_MODULE'] = 'backend.settings.prod'

    import requests.exceptions
    import celery.exceptions
    import tarfile
    import django.core.exceptions
    import django.urls
    import django.db
    import django.http
    import django.db.transaction
    import rest_framework.exceptions

    # Modules to inspect
    MODULES = [docker.errors, requests.exceptions, celery.exceptions, tarfile,
               django.core.exceptions, django.urls, django.db, django.http, django.db.transaction,
               rest_framework.exceptions]

    exceptions_clastes = set()

    # Add exceptions from modules
    for errors_module in MODULES:
        exceptions_clastes.update(find_exception(errors_module))

    # Add exceptions from python
    exception_tree(BaseException, exceptions_clastes)

    exceptions_clastes = sorted(exceptions_clastes)

    if os.path.exists(EXCEPTION_PATH) and append:
        # Append values to it
        json_exceptions = json.load(open(EXCEPTION_PATH))

        # get all new exceptions
        exceptions_clastes = [e for e in exceptions_clastes if e not in json_exceptions.keys()]

        # get the last value
        start_value = max(map(int, json_exceptions.values()))

        for code_exception, exception_name in enumerate(exceptions_clastes, start=start_value + 1):
            json_exceptions[exception_name] = f'{code_exception:04d}'

        return json_exceptions

    else:
        # Generate the json exceptions
        json_exceptions = dict()
        for code_exception, exception_name in enumerate(exceptions_clastes, start=1):
            json_exceptions[exception_name] = f'{code_exception:04d}'

        return json_exceptions

Ezoicreport this ad