2020-10-10 18:45:16 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pprint import pformat as pp
|
2020-10-10 21:14:21 +02:00
|
|
|
import sys
|
|
|
|
import argparse
|
2020-10-10 18:45:16 +02:00
|
|
|
|
|
|
|
import phi.ldap.client
|
|
|
|
from phi.config import get_config
|
|
|
|
from phi.logging import setup_logging, get_logger
|
|
|
|
|
|
|
|
log = get_logger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2020-10-10 21:14:21 +02:00
|
|
|
parser = argparse.ArgumentParser()
|
2020-10-10 18:45:16 +02:00
|
|
|
|
2020-10-10 21:14:21 +02:00
|
|
|
parser.add_argument('--config', metavar='config.yml',
|
|
|
|
type=str, help='custom configuration file')
|
|
|
|
|
|
|
|
ns = parser.parse_args(sys.argv[1:])
|
|
|
|
config_file = ns.config
|
2020-10-10 18:45:16 +02:00
|
|
|
|
2020-10-10 21:14:21 +02:00
|
|
|
config_file, config = get_config(config_file)
|
|
|
|
setup_logging(config.get('logging', {}))
|
|
|
|
log.info("Using configuration at '{}':\n".format(config_file))
|
2020-10-10 18:45:16 +02:00
|
|
|
|
|
|
|
log.info('Opening LDAP client')
|
|
|
|
client = phi.ldap.client.Client(**config['ldap'])
|
|
|
|
client.open()
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
log.info('Closing LDAP client')
|
|
|
|
client.close()
|