Namespaces | Functions | Variables
mycroft.util Namespace Reference

Namespaces

 audio_test
 
 combo_lock
 
 download
 
 format
 
 json_helper
 
 lang
 
 log
 
 parse
 
 signal
 
 time
 

Functions

def camel_case_split
 
def connected ()
 
def connected_dns (host="8.8.8.8", port=53, timeout=3)
 
def connected_ncsi ()
 
def create_daemon (target, args=(), kwargs=None)
 
def create_echo_function (name, whitelist=None)
 
def curate_cache (directory, min_free_percent=5.0, min_free_disk=50)
 
def find_input_device (device_name)
 
def get_arch ()
 
def get_cache_directory (domain=None)
 
def get_http (uri)
 
def is_speaking ()
 
def play_audio_file
 
def play_mp3 (uri)
 
def play_ogg (uri)
 
def play_wav (uri)
 
def read_dict (filename, div='=')
 
def read_stripped_lines (filename)
 
def record (file_path, duration, rate, channels)
 
def remove_last_slash (url)
 
def reset_sigint_handler ()
 
def resolve_resource_file (res_name)
 
def stop_speaking ()
 
def validate_param (value, name)
 
def wait_for_exit_signal ()
 
def wait_while_speaking ()
 

Variables

bool _log_all_bus_messages = False
 

Function Documentation

def mycroft.util.camel_case_split (   identifier)

Definition at line 519 of file scripts/mycroft/util/__init__.py.

def mycroft.util.connected ( )
Check connection by connecting to 8.8.8.8, if this is
blocked/fails, Microsoft NCSI is used as a backup

Returns:
    True if internet connection can be detected

Definition at line 259 of file scripts/mycroft/util/__init__.py.

def mycroft.util.connected_dns (   host = "8.8.8.8",
  port = 53,
  timeout = 3 
)
Check internet connection by connecting to DNS servers

Returns:
    True if internet connection can be detected

Definition at line 284 of file scripts/mycroft/util/__init__.py.

def mycroft.util.connected_ncsi ( )
Check internet connection by retrieving the Microsoft NCSI endpoint.

Returns:
    True if internet connection can be detected

Definition at line 269 of file scripts/mycroft/util/__init__.py.

def mycroft.util.create_daemon (   target,
  args = (),
  kwargs = None 
)
Helper to quickly create and start a thread with daemon = True

Definition at line 430 of file scripts/mycroft/util/__init__.py.

def mycroft.util.create_echo_function (   name,
  whitelist = None 
)
Standard logging mechanism for Mycroft processes.

This handles the setup of the basic logging for all Mycroft
messagebus-based processes.

Args:
    name (str): Reference name of the process
    whitelist (list, optional): List of "type" strings.  If defined, only
                                messages in this list will be logged.

Returns:
    func: The echo function

Definition at line 450 of file scripts/mycroft/util/__init__.py.

def mycroft.util.curate_cache (   directory,
  min_free_percent = 5.0,
  min_free_disk = 50 
)
Clear out the directory if needed

This assumes all the files in the directory can be deleted as freely

Args:
    directory (str): directory path that holds cached files
    min_free_percent (float): percentage (0.0-100.0) of drive to keep free,
                              default is 5% if not specified.
    min_free_disk (float): minimum allowed disk space in MB, default
                           value is 50 MB if not specified.

Definition at line 309 of file scripts/mycroft/util/__init__.py.

def mycroft.util.find_input_device (   device_name)
Find audio input device by name.

    Arguments:
        device_name: device name or regex pattern to match

    Returns: device_index (int) or None if device wasn't found

Definition at line 214 of file scripts/mycroft/util/__init__.py.

def mycroft.util.get_arch ( )
Get architecture string of system. 

Definition at line 417 of file scripts/mycroft/util/__init__.py.

def mycroft.util.get_cache_directory (   domain = None)
Get a directory for caching data

This directory can be used to hold temporary caches of data to
speed up performance.  This directory will likely be part of a
small RAM disk and may be cleared at any time.  So code that
uses these cached files must be able to fallback and regenerate
the file.

Args:
    domain (str): The cache domain.  Basically just a subdirectory.

Return:
    str: a path to the directory where you can cache data

Definition at line 358 of file scripts/mycroft/util/__init__.py.

def mycroft.util.get_http (   uri)

Definition at line 235 of file scripts/mycroft/util/__init__.py.

def mycroft.util.is_speaking ( )
Determine if Text to Speech is occurring

Returns:
    bool: True while still speaking

Definition at line 386 of file scripts/mycroft/util/__init__.py.

def mycroft.util.play_audio_file (   uri)

Definition at line 96 of file scripts/mycroft/util/__init__.py.

def mycroft.util.play_mp3 (   uri)
Play a mp3-file.

    This will use the application specified in the mycroft config
    and play the uri passed as argument. The function will return directly
    and play the file in the background.

    Arguments:
        uri:    uri to play

    Returns: subprocess.Popen object

Definition at line 152 of file scripts/mycroft/util/__init__.py.

def mycroft.util.play_ogg (   uri)
Play a ogg-file.

    This will use the application specified in the mycroft config
    and play the uri passed as argument. The function will return directly
    and play the file in the background.

    Arguments:
        uri:    uri to play

    Returns: subprocess.Popen object

Definition at line 178 of file scripts/mycroft/util/__init__.py.

def mycroft.util.play_wav (   uri)
Play a wav-file.

    This will use the application specified in the mycroft config
    and play the uri passed as argument. The function will return directly
    and play the file in the background.

    Arguments:
        uri:    uri to play

    Returns: subprocess.Popen object

Definition at line 126 of file scripts/mycroft/util/__init__.py.

def mycroft.util.read_dict (   filename,
  div = '=' 
)

Definition at line 250 of file scripts/mycroft/util/__init__.py.

def mycroft.util.read_stripped_lines (   filename)

Definition at line 245 of file scripts/mycroft/util/__init__.py.

def mycroft.util.record (   file_path,
  duration,
  rate,
  channels 
)

Definition at line 204 of file scripts/mycroft/util/__init__.py.

def mycroft.util.remove_last_slash (   url)

Definition at line 239 of file scripts/mycroft/util/__init__.py.

def mycroft.util.reset_sigint_handler ( )
Reset the sigint handler to the default. This fixes KeyboardInterrupt
not getting raised when started via start-mycroft.sh

Definition at line 422 of file scripts/mycroft/util/__init__.py.

def mycroft.util.resolve_resource_file (   res_name)
Convert a resource into an absolute filename.

Resource names are in the form: 'filename.ext'
or 'path/filename.ext'

The system wil look for ~/.mycroft/res_name first, and
if not found will look at /opt/mycroft/res_name,
then finally it will look for res_name in the 'mycroft/res'
folder of the source code package.

Example:
With mycroft running as the user 'bob', if you called
    resolve_resource_file('snd/beep.wav')
it would return either '/home/bob/.mycroft/snd/beep.wav' or
'/opt/mycroft/snd/beep.wav' or '.../mycroft/res/snd/beep.wav',
where the '...' is replaced by the path where the package has
been installed.

Args:
    res_name (str): a resource path/name
Returns:
    str: path to resource or None if no resource found

Definition at line 46 of file scripts/mycroft/util/__init__.py.

def mycroft.util.stop_speaking ( )

Definition at line 409 of file scripts/mycroft/util/__init__.py.

def mycroft.util.validate_param (   value,
  name 
)

Definition at line 381 of file scripts/mycroft/util/__init__.py.

def mycroft.util.wait_for_exit_signal ( )
Blocks until KeyboardInterrupt is received

Definition at line 438 of file scripts/mycroft/util/__init__.py.

def mycroft.util.wait_while_speaking ( )
Pause as long as Text to Speech is still happening

Pause while Text to Speech is still happening.  This always pauses
briefly to ensure that any preceeding request to speak has time to
begin.

Definition at line 397 of file scripts/mycroft/util/__init__.py.

Variable Documentation

bool mycroft.util._log_all_bus_messages = False
private

Definition at line 447 of file scripts/mycroft/util/__init__.py.



mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:41