forked from djib/PDMameUpdate
search for config file
This commit is contained in:
@ -48,6 +48,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
import pathlib
|
||||||
from clutch.core import Client
|
from clutch.core import Client
|
||||||
from tabulate import tabulate
|
from tabulate import tabulate
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
@ -58,8 +59,16 @@ from urllib.parse import quote
|
|||||||
def open_config_file():
|
def open_config_file():
|
||||||
"""Reads configuration from config.json file"""
|
"""Reads configuration from config.json file"""
|
||||||
|
|
||||||
logging.info('Opening config file: config.json')
|
for loc in os.environ.get("PDMAMEUPDATE_CONF"), "/etc", os.path.expanduser("~"), os.curdir:
|
||||||
with open('config.json') as config_file:
|
if loc is not None:
|
||||||
|
config_path = loc + '/config.json'
|
||||||
|
if pathlib.Path(config_path).is_file():
|
||||||
|
config_file_loc = config_path
|
||||||
|
break
|
||||||
|
|
||||||
|
logging.info('Opening config file: '+config_file_loc)
|
||||||
|
config_file = None;
|
||||||
|
with open(config_file_loc, 'r') as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user