39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# Copyright 2018 Mycroft AI Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
import os
|
|
from os.path import join, dirname, expanduser, exists
|
|
|
|
DEFAULT_CONFIG = join(dirname(__file__), 'mycroft.conf')
|
|
SYSTEM_CONFIG = os.environ.get('MYCROFT_SYSTEM_CONFIG',
|
|
'/etc/mycroft/mycroft.conf')
|
|
USER_CONFIG = join(expanduser('~'), '.mycroft/mycroft.conf')
|
|
REMOTE_CONFIG = "mycroft.ai"
|
|
WEB_CONFIG_CACHE = os.environ.get('MYCROFT_WEB_CACHE',
|
|
'/var/tmp/mycroft_web_cache.json')
|
|
|
|
|
|
def __ensure_folder_exists(path):
|
|
""" Make sure the directory for the specified path exists.
|
|
|
|
Arguments:
|
|
path (str): path to config file
|
|
"""
|
|
directory = dirname(path)
|
|
if not exists(directory):
|
|
os.makedirs(directory)
|
|
|
|
|
|
__ensure_folder_exists(WEB_CONFIG_CACHE)
|
|
__ensure_folder_exists(USER_CONFIG)
|