def loadPlugins(app, plugins): if not plugins: plugins = DEFAULT_PLUGINS for plugin in plugins: try: plugin_class = import_class(plugin) app.install(plugin_class()) except Exception as e: print("Failed to load plugin %s because of error %s" % (plugin, str(e))) continue
def get_key_func(key_func): """ Function to decide which key function to use. Defaults to ``default_key_func``. """ if key_func is not None: if callable(key_func): return key_func else: return import_class(key_func) return default_key_func
for date in decrypted ] if dates[0] < now < dates[1]: return True except: pass return False #----------------------------------------------------------------------------------------------------------------------- key_verification_function = config.get('throttling_key_verification_function') if key_verification_function: try: verified_key = import_class(key_verification_function) except ImportError: err = 'Error importing function %s' % key_verification_function print(err) raise Exception(err) else: if not AES: print( "API Key verification will be switched off - can't find pycrypto library" ) if not secret_key: print("API Key verification will be switched off - no AES key defined") verified_key = verify_key #-----------------------------------------------------------------------------------------------------------------------
from beaker import config from beaker.utils import import_class from beaker.throttle.backends.base import BaseThrottle throttle = None throttle_class = config.get( 'throttle_backend', 'beaker.throttle.backends.cacheThrottle.CacheThrottle') if throttle_class: try: throttle = import_class(throttle_class)() if not isinstance(throttle, BaseThrottle): print( "Configured throttle class (%s) is not a BaseThrottle instance, skipping throttling." % throttle_class) throttle = None except ImportError: print('Error importing %s' % throttle_class)
__author__ = 'mnowotka' from beaker import config from beaker.utils import import_class from beaker.cache.backends.base import BaseCache cache = None cache_class = config.get('cache_backend') if cache_class: try: cache = import_class(cache_class)() if not isinstance(cache, BaseCache): print("Configured cache class (%s) is not a BaseCache instance, skipping caching." % cache_class) cache = None except ImportError: print('Error importing %s' % cache_class)