26 """Get the directory used for Inter Process Communication 28 Files in this folder can be accessed by different processes on the 29 machine. Useful for communication. This is often a small RAM disk. 32 domain (str): The IPC domain. Basically a subdirectory to prevent 33 overlapping signal filenames. 36 str: a path to the IPC directory 38 config = mycroft.configuration.Configuration.get()
39 dir = config.get(
"ipc_path")
42 dir = os.path.join(tempfile.gettempdir(),
"mycroft",
"ipc")
47 """ Create a directory and give access rights to all 50 domain (str): The IPC domain. Basically a subdirectory to prevent 51 overlapping signal filenames. 54 str: a path to the directory 57 directory = os.path.join(directory, domain)
60 directory = os.path.normpath(directory)
61 directory = os.path.expanduser(directory)
63 if not os.path.isdir(directory):
66 os.makedirs(directory, 0o777)
68 LOG.warning(
"Failed to create: " + directory)
77 """ Create the file filename and create any directories needed 80 filename: Path to the file to be created 83 os.makedirs(os.path.dirname(filename))
86 with open(filename,
'w')
as f:
91 """Create a named signal 94 signal_name (str): The signal's name. Must only contain characters 100 return os.path.isfile(path)
106 """See if a named signal exists 109 signal_name (str): The signal's name. Must only contain characters 111 sec_lifetime (int, optional): How many seconds the signal should 112 remain valid. If 0 or not specified, it is a single-use signal. 113 If -1, it never expires. 116 bool: True if the signal is defined, False otherwise 119 if os.path.isfile(path):
120 if sec_lifetime == 0:
123 elif sec_lifetime == -1:
125 elif int(os.path.getctime(path) + sec_lifetime) < int(time.time()):
def check_for_signal(signal_name, sec_lifetime=0)
def create_file(filename)
def create_signal(signal_name)
def ensure_directory_exists(directory, domain=None)
def get_ipc_directory(domain=None)