Commit f86a658d authored by Lorenz Steinert's avatar Lorenz Steinert

return error and dont exit

parent 89f3b497
......@@ -29,6 +29,8 @@ class Error(Flag):
NO_FILE = auto()
LDAP_FAIL = auto()
NO_DEFAULT_FILE = auto()
NO_DIR = auto()
NO_DEFAULT_DIR = auto()
def current_user():
......@@ -305,18 +307,17 @@ def get_share(rundir, config=None, sharedir=None):
if os.path.isdir(sharedir):
return sharedir
logging.warning(sharedir + ': Not a Directory')
sys.exit(2)
return Error.NO_DIR
elif config:
if os.path.isdir(config['PROTOKOLL']['share']):
return config['PROTOKOLL']['share']
logging.warning(config['PROTOKOLL']['share'] + ': Not a Directory')
sys.exit(2)
return Error.NO_DIR
elif os.path.isdir(os.path.join(rundir, '../share')):
return os.path.join(rundir, '../share')
logging.warning('No share Directory found at '
+ os.path.abspath(os.path.join(rundir, '../share')))
sys.exit(1)
return Error.NO_DEFAULT_DIR
def get_path(rundir, config=None, path=None):
"""get the location of the protokoll directory"""
......@@ -324,17 +325,17 @@ def get_path(rundir, config=None, path=None):
if os.path.isdir(path):
return path
logging.warning(path + ': Not a Directory')
sys.exit(2)
return Error.NO_DIR
elif config:
if os.path.isdir(config['PROTOKOLL']['path']):
return config['PROTOKOLL']['path']
logging.warning(config['PROTOKOLL']['path'] + ': Not a Directory')
sys.exit(2)
return Error.NO_DIR
elif os.path.isdir(os.path.join(rundir, '../..')):
return os.path.join(rundir, '../..')
logging.warning('No Protokoll Directory found at '
+ os.path.abspath(os.path.join(rundir, '../..')))
sys.exit(1)
return Error.NO_DEFAULT_DIR
def get_ldap_server(config=None, server=None):
......
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