Commit b10f7ad1 authored by Lorenz Steinert's avatar Lorenz Steinert

added get_server_timeout function to esme

parent 8e0650ab
......@@ -298,3 +298,12 @@ def get_ldap_base(config=None, base=None):
else:
print("No LDAP search base supplied. Triing to use \"dc=fs,dc=physik,dc=uni-kl,dc=de\".")
return "dc=fs,dc=physik,dc=uni-kl,dc=de"
def get_server_timeout(config=None, test=None):
"""get the timeout for the connection to the ldap server"""
if test:
return 1
elif config:
return config['SERVER'].getint('connect_timeout')
else:
return 10
......@@ -12,7 +12,7 @@ import sys
import shutil
import codecs
import argparse
from module.esme import FsrLdap, get_date, get_sprecher, get_config, get_share, get_path, get_ldap_server, get_ldap_base
from module.esme import FsrLdap, get_date, get_sprecher, get_config, get_share, get_path, get_ldap_server, get_ldap_base, get_server_timeout
def build_parser():
......@@ -175,6 +175,7 @@ if __name__ == "__main__":
SHARE_DIR = get_share(RUNDIR, CONFIG, OPT.sharedir)
LDAP_SERVER = get_ldap_server(CONFIG, OPT.server)
LDAP_SERVER_BASE = get_ldap_base(CONFIG, OPT.base)
SERVER_TIMEOUT = get_server_timeout(CONFIG, OPT.test)
REG = {'SPR': re.compile('%%SPRECHER'),
'PRO': re.compile('%%PROTOKOLLANT'),
......@@ -190,13 +191,8 @@ if __name__ == "__main__":
NUM_COLS = 5
NUM_COLS_EXT = 5
#Set the timeout to 1 if we just want to test stuff
if OPT.test:
ESME = FsrLdap(LDAP_SERVER, LDAP_SERVER_BASE, OPT.debug,
timeout=1)
else:
ESME = FsrLdap(LDAP_SERVER, LDAP_SERVER_BASE, OPT.debug,
timeout=CONFIG['SERVER'].getint('connect_timeout'))
ESME = FsrLdap(LDAP_SERVER, LDAP_SERVER_BASE, OPT.debug,
SERVER_TIMEOUT)
print("\n")
print("Wenn der Standardwert (in []) stimmt einfach Enter!\n")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment