Commit 8e0650ab authored by Lorenz Steinert's avatar Lorenz Steinert

moved check for config to the get functions

parent 156f26ff
......@@ -38,24 +38,24 @@ class FsrLdap:
connect_timeout=timeout)
self.base = base
def get_protokollant_ldap(self, protokollant):
def get_protokollant_ldap(self, config):
"""search the LDAP for the current user"""
print("Fetching Protokollant from LDAP ...")
try:
conn = ldap.Connection(self.server)
conn.bind()
fil = "(uid="+current_user()+")"
if conn.search('ou=people,'+self.base, fil,
if conn.search('ou=people,' + self.base, fil,
attributes=['displayName']):
return " ".join(str(conn.entries[0]['displayName']).split(", ")[::-1])
return get_protokollant(protokollant)
return get_protokollant(config)
except ldap.core.exceptions.LDAPException as error_message:
if self.debug:
print("Couldn't Connect to ldap.\n \
Using fallback default.\n%s\n" % error_message)
else:
print("Couldn't Connect to ldap.\nUsing fallback default.\n")
return get_protokollant(protokollant)
return get_protokollant(config)
def get_fsr_ldap(self, share_dir):
"""get fsr from LDAP"""
......@@ -142,16 +142,24 @@ def get_fallback_fsr_extern(share_dir):
return []
def get_sprecher(sprecher):
"""get sprecher from user input"""
def get_sprecher(config=None):
"""get sprecher from user input or config"""
if config:
sprecher = config['DEFAULT']['Sprecher']
else:
sprecher = ''
stmp = input("Sprecher ["+sprecher+"]: ")
if stmp != "":
return stmp
return sprecher
def get_protokollant(protokollant):
"""get protokollant from user input"""
def get_protokollant(config=None):
"""get protokollant from user input or config"""
if config:
protokollant = config['DEFAULT']['Protokollant']
else:
protokollant = ''
ptmp = input("Protokollant ["+protokollant+"]: ")
if ptmp != "":
return ptmp
......
......@@ -201,12 +201,8 @@ if __name__ == "__main__":
print("\n")
print("Wenn der Standardwert (in []) stimmt einfach Enter!\n")
if CONFIG:
SPRECHER = get_sprecher(CONFIG['DEFAULT']['Sprecher'])
PROTOKOLLANT = ESME.get_protokollant_ldap(CONFIG['DEFAULT']['Protokollant'])
else:
SPRECHER = get_sprecher('')
PROTOKOLLANT = ESME.get_protokollant_ldap('')
SPRECHER = get_sprecher(CONFIG)
PROTOKOLLANT = ESME.get_protokollant_ldap(CONFIG)
DATE = get_date(OPT.test)
......
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