Exemple #1
0
    def on_exception(self, source, exc_info):
        log.info('Exception raised in %s: %s', source, exc_info[1], exc_info=True)

        # Raise exception if the database is already disabled
        if disabled_databases.get(self.name):
            raise DatabaseDisabledError(exc_info[1])

        # Mark database as disabled
        disabled_databases[self.name] = exc_info

        # Emit exception event
        ExceptionWrapper.add(source, exc_info, self.name)

        # Raise exception
        raise DatabaseDisabledError(exc_info[1])
Exemple #2
0
    def on_exception(self, source, exc_info):
        log.info('Exception raised in %s: %s',
                 source,
                 exc_info[1],
                 exc_info=True)

        # Raise exception if the database is already disabled
        if disabled_databases.get(self.name):
            raise DatabaseDisabledError(exc_info[1])

        # Mark database as disabled
        disabled_databases[self.name] = exc_info

        # Emit exception event
        ExceptionWrapper.add(source, exc_info, self.name)

        # Raise exception
        raise DatabaseDisabledError(exc_info[1])
# Try import "peewee", generate skeleton if an error is raised
try:
    from peewee import *
    from peewee import Database
except ImportError as ex:
    # Generate skeleton database class
    class Database(object):
        commit_select = False

# Try import "playhouse.apsw_ext", generate skeleton if an error is raised
try:
    from playhouse.apsw_ext import *
    exw_enabled = True
except ImportError as ex:
    # Emit event
    ExceptionWrapper.add(ExceptionSource.Peewee, sys.exc_info(), 'playhouse.apsw_ext')

    # Update module state
    exw_exception = ex
    exw_exc_info = sys.exc_info()

    # Generate skeleton cursor class
    class Cursor(object):
        lastrowid = 0
        rowcount = 0

        def execute(self, *args, **kwargs):
            raise ModuleDisabledError(exw_exception)

        def fetchone(self, *args, **kwargs):
            raise ModuleDisabledError(exw_exception)
Exemple #4
0
import sys


exw_enabled = False

exw_exception = None
exw_exc_info = (None, None, None)

# Try import "apsw", generate skeleton if an error is raised
try:
    from apsw import *

    exw_enabled = True
except ImportError as ex:
    # Emit event
    ExceptionWrapper.add(ExceptionSource.APSW, sys.exc_info(), 'apsw')

    # Update module state
    exw_exception = ex
    exw_exc_info = sys.exc_info()

    # Generate skeleton cursor class
    class Cursor(object):
        lastrowid = 0
        rowcount = 0

        def execute(self, *args, **kwargs):
            raise ModuleDisabledError(exw_exception)

        def fetchone(self, *args, **kwargs):
            raise ModuleDisabledError(exw_exception)