예제 #1
0
파일: trigger.py 프로젝트: tracsa/cacahuate
    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
예제 #2
0
파일: main.py 프로젝트: tracsa/charpe
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()
예제 #3
0
#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)