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