Example #1
0
def save_remote_settings_cache(remote_settings):
    """Save updated remote settings to cache file.

    Arguments:
        remote_settings (dict): downloaded remote settings.
    """
    try:
        ensure_directory_exists(dirname(str(REMOTE_CACHE)))
        with open(str(REMOTE_CACHE), 'w') as cache:
            json.dump(remote_settings, cache)
    except Exception as error:
        LOG.warning('Failed to write remote_cache. ({})'.format(error))
    else:
        LOG.debug('Updated local cache of remote skill settings.')
Example #2
0
 def __init__(self, tts_config, tts_name, audio_file_type):
     self.config = tts_config
     self.tts_name = tts_name
     if "preloaded_cache" in self.config:
         self.persistent_cache_dir = Path(self.config["preloaded_cache"])
     else:
         self.persistent_cache_dir = None
     self.temporary_cache_dir = Path(get_cache_directory("tts/" + tts_name))
     self.audio_file_type = audio_file_type
     self.resource_dir = Path(__file__).parent.parent.joinpath("res")
     self.cached_sentences = dict()
     ensure_directory_exists(str(self.persistent_cache_dir),
                             permissions=0o755)
     ensure_directory_exists(str(self.temporary_cache_dir),
                             permissions=0o755)
Example #3
0
    def __init__(self, url, dest, complete_action=None, header=None):
        super(Downloader, self).__init__()
        self.url = url
        self.dest = dest
        self.complete_action = complete_action
        self.status = None
        self.done = False
        self._abort = False
        self.header = header

        # Create directories as needed
        ensure_directory_exists(dirname(dest), permissions=0o775)

        #  Start thread
        self.daemon = True
        self.start()
Example #4
0
def get_ipc_directory(domain=None):
    """Get the directory used for Inter Process Communication

    Files in this folder can be accessed by different processes on the
    machine.  Useful for communication.  This is often a small RAM disk.

    Args:
        domain (str): The IPC domain.  Basically a subdirectory to prevent
            overlapping signal filenames.

    Returns:
        str: a path to the IPC directory
    """
    config = mycroft.configuration.Configuration.get()
    dir = config.get("ipc_path")
    if not dir:
        # If not defined, use /tmp/mycroft/ipc
        dir = os.path.join(tempfile.gettempdir(), "mycroft", "ipc")
    return ensure_directory_exists(dir, domain)