def config(): ''' Returns a fully loaded configuration dict ''' con = Config( os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) con.from_object('charpe.settings') return con
def main(): # Load the config config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_object('cacahuate.settings') config.from_envvar('CACAHUATE_SETTINGS', silent=True) # Set the timezone os.environ['TZ'] = config['TIMEZONE'] time.tzset() # Setup logging logging.config.dictConfig(config['LOGGING']) # Load the models eng = Engine( host=config['REDIS_HOST'], port=config['REDIS_PORT'], db=config['REDIS_DB'], id_function=yuid, ) bind_models(eng) # Create mongo indexes create_indexes(config) # start the loop loop = Loop(config) loop.start()
def config(): ''' Returns a fully loaded configuration dict ''' con = Config( os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) con.from_object('cacahuate.settings') con.from_mapping(TESTING_SETTINGS) return con
def main(): # Load the config config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_object('cacahuate.settings') if os.getenv('CACAHUATE_SETTINGS'): config.from_envvar('CACAHUATE_SETTINGS', silent=False) # Set the timezone os.environ['TZ'] = config['TIMEZONE'] time.tzset() # Setup logging logging.config.dictConfig(config['LOGGING']) # Load the models eng = Engine( host=config['REDIS_HOST'], port=config['REDIS_PORT'], db=config['REDIS_DB'], id_function=getattr( import_module(config['DB_ID_FUNCTION'].rsplit('.', 1)[0]), config['DB_ID_FUNCTION'].rsplit('.', 1)[1], ), ) bind_models(eng) # Create mongo indexes create_indexes(config) # Update celery config celery.conf.update( broker='amqp://{user}@{host}//'.format( user=config['RABBIT_USER'], host=config['RABBIT_HOST'], ), worker_concurrency=1, worker_hijack_root_logger=False, task_default_queue=config['RABBIT_QUEUE'], ) worker = celery.Worker() worker.start()
def __init__(self): config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_pyfile('settings.py') config.from_envvar('CACAHUATE_SETTINGS', silent=True) connection = pika.BlockingConnection( pika.ConnectionParameters(host=config['RABBIT_HOST'], )) channel = connection.channel() channel.queue_declare( queue=config['RABBIT_QUEUE'], durable=True, ) self.config = config self.channel = channel
def main(): # Load the config config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_pyfile('settings.py') config.from_envvar('CHARPE_SETTINGS', silent=False) # Set the timezone os.environ['TZ'] = config['TIMEZONE'] time.tzset() # Logging stuff import logging logging.basicConfig( format='[%(levelname)s] %(message)s - %(name)s:%(lineno)s', level=config['LOG_LEVEL'], ) # Run the event loop loop = Loop(config) loop.start()
#Bind to the server try: client.protocol_version = ldap.VERSION3 client.simple_bind_s(binddn, pw) except ldap.INVALID_CREDENTIALS: print("Your username or password is incorrect.") sys.exit(0) except ldap.LDAPError as e: if type(e.message) == dict and e.message.has_key('desc'): print(e.message['desc']) else: print(e) sys.exit(0) try: res = client.search_s(config['BIND_DN'], searchScope, searchFilter, searchAttribute) pprint(res) except ldap.LDAPError as e: print(e) client.unbind_s() if __name__ == '__main__': config = Config(os.path.dirname(os.path.realpath(__file__))) config.from_pyfile('settings.py') config.from_envvar('LDAP_SETTINGS', silent=False) main(config)