Commit 89f3b497 authored by Lorenz Steinert's avatar Lorenz Steinert

lock if Flag type as it will raise an error in 3.8

parent 157831d4
......@@ -28,6 +28,8 @@ class Error(Flag):
UNSEC_SEARCH = auto()
NO_FILE = auto()
LDAP_FAIL = auto()
NO_DEFAULT_FILE = auto()
def current_user():
"""get the current user"""
......@@ -105,10 +107,11 @@ class FsrLdap:
if isinstance(protokollant, tuple):
pass
protokollant = protokollant[0]
if protokollant == Error.UNSEC_SEARCH | Error.LDAP_FAIL:
protokollant = self._get_fallback_protokollant(config)
if protokollant == Error.NO_FILE:
protokollant = ""
elif isinstance(protokollant, Flag):
if protokollant in Error.UNSEC_SEARCH | Error.LDAP_FAIL:
protokollant = self._get_fallback_protokollant(config)
if protokollant == Error.NO_FILE:
protokollant = ""
return protokollant
def _get_fsr_ldap(self):
......@@ -157,10 +160,11 @@ class FsrLdap:
if isinstance(fsr, tuple):
pass
fsr = fsr[0]
if fsr == Error.UNSEC_SEARCH | Error.LDAP_FAIL and not gen_fallback:
fsr = self._get_fallback_fsr(share_dir)
if fsr == Error.NO_FILE | Error.UNSEC_SEARCH:
fsr = []
elif isinstance(fsr, Flag):
if fsr == Error.UNSEC_SEARCH | Error.LDAP_FAIL and not gen_fallback:
fsr = self._get_fallback_fsr(share_dir)
if fsr == Error.NO_FILE | Error.UNSEC_SEARCH:
fsr = []
return resort_fsr(fsr)
def _get_fsr_extern_ldap(self):
......@@ -205,15 +209,16 @@ class FsrLdap:
if not share_dir:
share_dir = self.share_dir
fsr = self._get_fsr_extern_ldap()
if isinstance(fsr, tuple):
fsr_extern = self._get_fsr_extern_ldap()
if isinstance(fsr_extern, tuple):
pass
fsr = fsr[0]
if fsr == Error.UNSEC_SEARCH | Error.LDAP_FAIL and not gen_fallback:
fsr = self._get_fallback_fsr_extern(share_dir)
if fsr == Error.NO_FILE | Error.UNSEC_SEARCH:
fsr = []
return resort_fsr(fsr)
fsr_extern = fsr_extern[0]
if isinstance(fsr_extern, Flag):
if fsr_extern == Error.UNSEC_SEARCH | Error.LDAP_FAIL and not gen_fallback:
fsr_extern = self._get_fallback_fsr_extern(share_dir)
if fsr_extern == Error.NO_FILE | Error.UNSEC_SEARCH:
fsr_extern = []
return resort_fsr(fsr_extern)
def get_sprecher(config=None):
......@@ -227,8 +232,6 @@ def get_sprecher(config=None):
return sprecher
def get_date(test=False):
"""get current date then ask user"""
if test:
......@@ -272,7 +275,7 @@ def get_config(rundir, config_path=None, default=False):
config.read(config_path)
return config
logging.warning(config_path + ': Not a file')
sys.exit(2)
return Error.NO_FILE
elif default:
if os.path.isfile(os.path.join(rundir, '../etc/proto.ini.default')):
config = configparser.ConfigParser()
......@@ -281,7 +284,7 @@ def get_config(rundir, config_path=None, default=False):
logging.warning('No default File found at '
+ os.path.abspath(os.path.join(rundir,
'../etc/proto.ini.default')))
sys.exit(1)
return Error.NO_DEFAULT_FILE
elif os.path.isfile(os.path.join(rundir,
'../etc/proto.ini')) and not default:
config = configparser.ConfigParser()
......@@ -293,7 +296,7 @@ def get_config(rundir, config_path=None, default=False):
config.read(os.path.join(rundir, '../etc/proto.ini.default'))
return config
logging.warning('No ini file found. Using hardcoded defaults.')
return None
return Error.NO_DEFAULT_FILE
def get_share(rundir, config=None, sharedir=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