Commit 8bb77227 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Remove fail on non required sections of config + fix default for sqlite db

parent bac9e755
...@@ -156,7 +156,7 @@ class AppConfigReader: ...@@ -156,7 +156,7 @@ class AppConfigReader:
def _get_database_type(self): def _get_database_type(self):
try: try:
return self.reader.get("database", "type") return self.reader.get("database", "type")
except NoOptionError: except (NoSectionError, NoOptionError):
return "sqlite" return "sqlite"
def _get_database_url(self): def _get_database_url(self):
...@@ -170,13 +170,13 @@ class AppConfigReader: ...@@ -170,13 +170,13 @@ class AppConfigReader:
except FileNotFoundError: except FileNotFoundError:
pass pass
return url return url
except NoOptionError: except (NoSectionError, NoOptionError):
return ":memory:" return self._replace_vars("###USER###/.dgenies/database.sqlite")
def _get_database_port(self): def _get_database_port(self):
try: try:
return int(self.reader.get("database", "port")) return int(self.reader.get("database", "port"))
except (NoOptionError, ValueError): except (NoSectionError, NoOptionError, ValueError):
db_type = self._get_database_type() db_type = self._get_database_type()
if db_type == "mysql": if db_type == "mysql":
return 3306 return 3306
...@@ -190,7 +190,7 @@ class AppConfigReader: ...@@ -190,7 +190,7 @@ class AppConfigReader:
if db == "": if db == "":
raise ValueError() raise ValueError()
return db return db
except (NoOptionError, ValueError): except (NoSectionError, NoOptionError, ValueError):
if self._get_database_type() == "sqlite": if self._get_database_type() == "sqlite":
return "" return ""
raise Exception("Missing parameter: database db name") raise Exception("Missing parameter: database db name")
...@@ -201,7 +201,7 @@ class AppConfigReader: ...@@ -201,7 +201,7 @@ class AppConfigReader:
if user == "": if user == "":
raise ValueError() raise ValueError()
return user return user
except (NoOptionError, ValueError): except (NoSectionError, NoOptionError, ValueError):
if self._get_database_type() == "sqlite": if self._get_database_type() == "sqlite":
return "" return ""
raise Exception("Missing parameter: database user") raise Exception("Missing parameter: database user")
...@@ -212,7 +212,7 @@ class AppConfigReader: ...@@ -212,7 +212,7 @@ class AppConfigReader:
if passwd == "": if passwd == "":
raise ValueError() raise ValueError()
return passwd return passwd
except (NoOptionError, ValueError): except (NoSectionError, NoOptionError, ValueError):
if self._get_database_type() == "sqlite": if self._get_database_type() == "sqlite":
return "" return ""
raise Exception("Missing parameter: database password") raise Exception("Missing parameter: database password")
...@@ -220,31 +220,31 @@ class AppConfigReader: ...@@ -220,31 +220,31 @@ class AppConfigReader:
def _get_mail_status_sender(self): def _get_mail_status_sender(self):
try: try:
return self._replace_vars(self.reader.get("mail", "status")) return self._replace_vars(self.reader.get("mail", "status"))
except NoOptionError: except (NoSectionError, NoOptionError):
return "status@dgenies" return "status@dgenies"
def _get_mail_reply(self): def _get_mail_reply(self):
try: try:
return self._replace_vars(self.reader.get("mail", "reply")) return self._replace_vars(self.reader.get("mail", "reply"))
except NoOptionError: except (NoSectionError, NoOptionError):
return "status@dgenies" return "status@dgenies"
def _get_mail_org(self): def _get_mail_org(self):
try: try:
return self._replace_vars(self.reader.get("mail", "org")) return self._replace_vars(self.reader.get("mail", "org"))
except NoOptionError: except (NoSectionError, NoOptionError):
return None return None
def _get_send_mail_status(self): def _get_send_mail_status(self):
try: try:
return self.reader.get("mail", "send_mail_status").lower() == "true" return self.reader.get("mail", "send_mail_status").lower() == "true"
except NoOptionError: except (NoSectionError, NoOptionError):
return True return True
def _get_disable_mail(self): def _get_disable_mail(self):
try: try:
return self.reader.get("mail", "disable").lower() == "true" return self.reader.get("mail", "disable").lower() == "true"
except NoOptionError: except (NoSectionError, NoOptionError):
return False return False
def _get_cron_clean_time(self): def _get_cron_clean_time(self):
......
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