handle config file existence

This commit is contained in:
2023-01-14 13:35:33 +01:00
parent 4ca58629e8
commit 17f675fa09
+9 -5
View File
@@ -2,15 +2,19 @@ import configparser
import getpass import getpass
import os import os
from pathlib import Path from pathlib import Path
home = str(Path.home()) home = str(Path.home())
config = configparser.ConfigParser() config = configparser.ConfigParser()
# check the config file existence # check the config file existence
config_file_path = home + "/config.ini" config_file_path = home + "/config.ini"
config.read(config_file_path) if Path(config_file_path).is_file():
CONTACT_LIST_FILE = config['DEFAULT']['contact_list_file'] config.read(config_file_path)
FIREBASE_CONFIG_FILE = config['DEFAULT']['firebase_config_file'] CONTACT_LIST_FILE = config['DEFAULT']['contact_list_file']
LOGS_DIR = config['DEFAULT']['LOGS_DIR'] FIREBASE_CONFIG_FILE = config['DEFAULT']['firebase_config_file']
LOGS_DIR = config['DEFAULT']['LOGS_DIR']
else:
print("config file not found")
username = getpass.getuser() username = getpass.getuser()
LOG_SOURCE = username LOG_SOURCE = username
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.dirname(os.path.abspath(__file__))