Commit c32351a3 authored by Lorenz Steinert's avatar Lorenz Steinert

using mock funktions so changed esme.py back

parent 2bd98c8f
......@@ -38,14 +38,11 @@ class FsrLdap:
connect_timeout=timeout)
self.base = base
def get_protokollant_ldap(self, config, testing=False):
def get_protokollant_ldap(self, config):
"""search the LDAP for the current user"""
print("Fetching Protokollant from LDAP ...")
try:
if testing:
conn = ldap.Connection(self.server, ldap.MOCK_SYNC)
else:
conn = ldap.Connection(self.server)
conn = ldap.Connection(self.server)
conn.bind()
fil = "(uid="+current_user()+")"
if conn.search('ou=people,' + self.base, fil,
......@@ -61,14 +58,11 @@ class FsrLdap:
print("Couldn't Connect to ldap.\nUsing fallback default.\n")
return get_protokollant(config)
def get_fsr_ldap(self, share_dir=None, gen_fallback=False, testing=False):
def get_fsr_ldap(self, share_dir=None, gen_fallback=False):
"""get fsr from LDAP"""
print("Fetching FSR from LDAP ...")
try:
if testing:
conn = ldap.Connection(self.server, client_strategy=ldap.MOCK_SYNC)
else:
conn = ldap.Connection(self.server)
conn = ldap.Connection(self.server)
conn.bind()
fil = '(cn=intern)'
fsr = []
......@@ -95,14 +89,11 @@ class FsrLdap:
if not gen_fallback:
return get_fallback_fsr(share_dir)
def get_fsr_extern_ldap(self, share_dir=None, gen_fallback=False, testing=False):
def get_fsr_extern_ldap(self, share_dir=None, gen_fallback=False):
"""get the EFSR from LDAP"""
print("Fetching EFSR from LDAP ...")
try:
if testing:
conn = ldap.Connection(self.server, client_strategy=ldap.MOCK_SYNC)
else:
conn = ldap.Connection(self.server)
conn = ldap.Connection(self.server)
conn.bind()
fil = '(cn=extern)'
fsr_extern = []
......@@ -158,29 +149,29 @@ def get_fallback_fsr_extern(share_dir):
return []
def get_sprecher(config=None, getinput=input):
def get_sprecher(config=None):
"""get sprecher from user input or config"""
sprecher = ''
if config:
sprecher = config['PROTOKOLL']['Sprecher']
stmp = getinput("Sprecher ["+sprecher+"]: ")
stmp = input("Sprecher ["+sprecher+"]: ")
if stmp != "":
return stmp
return sprecher
def get_protokollant(config=None, getinput=input):
def get_protokollant(config=None):
"""get protokollant from user input or config"""
protokollant = ''
if config:
protokollant = config['PROTOKOLL']['Protokollant']
ptmp = getinput("Protokollant ["+protokollant+"]: ")
ptmp = input("Protokollant ["+protokollant+"]: ")
if ptmp != "":
return ptmp
return protokollant
def get_date(test=False, getinput=input):
def get_date(test=False):
"""get current date then ask user"""
if test:
date = ('01.01.2000', '2000', '01', '01')
......@@ -194,7 +185,7 @@ def get_date(test=False, getinput=input):
day = "0"+day
date = (day + '.' + mon + '.' + year, year, mon, day)
dtmp = getinput("Datum ["+date[0]+"]: ")
dtmp = input("Datum ["+date[0]+"]: ")
if dtmp != "":
day, mon, year = dtmp.split('.')
if len(mon) < 2:
......@@ -207,9 +198,9 @@ def get_date(test=False, getinput=input):
return date
def get_editor(editor, getinput=input):
def get_editor(editor):
"""get the editor to use from user input"""
etmp = getinput("Editor ["+editor+"]: ")
etmp = input("Editor ["+editor+"]: ")
if etmp != "":
return etmp
return editor
......
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