Exemple #1
0
def _read_data():
    """ Reads the file in (/tmp/mycroft/ipc/managers/disp_info)
        and returns the the data as python dict
    """
    managerIPCDir = os.path.join(get_ipc_directory(), "managers")

    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)

    data = {}
    try:
        with open(path, permission) as dispFile:

            if os.stat(str(dispFile.name)).st_size != 0:
                data = json.load(dispFile)

    except Exception as e:
        LOG.error(e)
        os.remove(path)
        _read_data()

    return data
def main():
    # Monitor system logs
    config = Configuration.get()
    if 'log_dir' in config:
        log_dir = os.path.expanduser(config['log_dir'])
        start_log_monitor(os.path.join(log_dir, 'skills.log'))
        start_log_monitor(os.path.join(log_dir, 'voice.log'))
    else:
        start_log_monitor("/var/log/mycroft/skills.log")
        start_log_monitor("/var/log/mycroft/voice.log")

    # Monitor IPC file containing microphone level info
    start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))

    connect_to_mycroft()
    if '--simple' in sys.argv:
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        simple_cli()
    else:
        # Special signal handler allows a clean shutdown of the GUI
        signal.signal(signal.SIGINT, ctrl_c_handler)
        load_settings()
        curses.wrapper(gui_main)
        curses.endwin()
        save_settings()
Exemple #3
0
 def __init__(self, wake_word_recognizer):
     speech_recognition.Recognizer.__init__(self)
     self.wake_word_recognizer = wake_word_recognizer
     self.audio = pyaudio.PyAudio()
     self.multiplier = listener_config.get('multiplier')
     self.energy_ratio = listener_config.get('energy_ratio')
     self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
Exemple #4
0
    def __init__(self, wake_word_recognizer):

        self.config = Configuration.get()
        listener_config = self.config.get('listener')
        self.upload_url = listener_config['wake_word_upload']['url']
        self.upload_disabled = listener_config['wake_word_upload']['disable']
        self.wake_word_name = wake_word_recognizer.key_phrase

        self.overflow_exc = listener_config.get('overflow_exception', False)

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')
        # check the config for the flag to save wake words.

        self.save_utterances = listener_config.get('record_utterances', False)
        self.upload_lock = Lock()
        self.filenames_to_upload = []
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
        self._stop_signaled = False

        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = wake_word_recognizer.num_phonemes
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.TEST_WW_SEC = num_phonemes * len_phoneme
        self.SAVED_WW_SEC = max(3, self.TEST_WW_SEC)

        try:
            self.account_id = DeviceApi().get()['user']['uuid']
        except (requests.RequestException, AttributeError):
            self.account_id = '0'
Exemple #5
0
 def __init__(self, wake_word_recognizer):
     speech_recognition.Recognizer.__init__(self)
     self.wake_word_recognizer = wake_word_recognizer
     self.audio = pyaudio.PyAudio()
     self.multiplier = listener_config.get('multiplier')
     self.energy_ratio = listener_config.get('energy_ratio')
     self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
Exemple #6
0
    def get_listener_level(self):
        """ Get level from IPC file created by listener. """
        time.sleep(0.05)
        if not self.listener_file:
            try:
                self.listener_file = os.path.join(get_ipc_directory(),
                                                  'mic_level')
            except FileNotFoundError:
                return None

        try:
            st_results = os.stat(self.listener_file)

            if (not st_results.st_ctime == self.st_results.st_ctime
                    or not st_results.st_mtime == self.st_results.st_mtime):
                ret = read_file_from(self.listener_file, 0)
                self.st_results = st_results
                if ret is not None:
                    if ret > self.max_amplitude:
                        self.max_amplitude = ret
                    ret = int(ret / self.max_amplitude * 10)
                return ret
        except Exception as e:
            self.log.error(repr(e))
        return None
Exemple #7
0
    def __init__(self, wake_word_recognizer):

        self.config = ConfigurationManager.instance()
        listener_config = self.config.get('listener')
        self.upload_config = listener_config.get('wake_word_upload')
        self.wake_word_name = listener_config['wake_word']
        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = wake_word_recognizer.num_phonemes
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.TEST_WW_SEC = int(num_phonemes * len_phoneme)
        self.SAVED_WW_SEC = (10 if self.upload_config['enable']
                             else self.TEST_WW_SEC)

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')
        # check the config for the flag to save wake words.

        self.save_utterances = listener_config.get('record_utterances', False)
        self.save_wake_words = listener_config.get('record_wake_words') \
            or self.upload_config['enable'] or self.config['opt_in']
        self.upload_lock = Lock()
        self.save_wake_words_dir = join(gettempdir(), 'mycroft_wake_words')
        self.filenames_to_upload = []
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
        self._stop_signaled = False
Exemple #8
0
def _read_data():
    """ Writes the dictionary of state data from the IPC directory.
    Returns:
        dict: loaded state information
    """
    managerIPCDir = os.path.join(get_ipc_directory(), "managers")

    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)

    data = {}
    try:
        with open(path, permission) as dispFile:

            if os.stat(str(dispFile.name)).st_size != 0:
                data = json.load(dispFile)

    except Exception as e:
        LOG.error(e)
        os.remove(path)
        _read_data()

    return data
def _read_data():
    """ Reads the file in (/tmp/mycroft/ipc/managers/disp_info)
        and returns the the data as python dict
    """
    managerIPCDir = os.path.join(get_ipc_directory(), "managers")

    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)

    data = {}
    try:
        with open(path, permission) as dispFile:

            if os.stat(str(dispFile.name)).st_size != 0:
                data = json.load(dispFile)

    except Exception as e:
        LOG.error(e)
        os.remove(path)
        _read_data()

    return data
Exemple #10
0
    def __init__(self, wake_word_recognizer, hot_word_engines=None):
        if hot_word_engines is None:
            hot_word_engines = {}
        self.config = ConfigurationManager.instance()
        listener_config = self.config.get('listener')
        self.upload_config = listener_config.get('wake_word_upload')
        self.wake_word_name = listener_config['wake_word']
        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = wake_word_recognizer.num_phonemes
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.TEST_WW_SEC = int(num_phonemes * len_phoneme)
        self.SAVED_WW_SEC = (10 if self.upload_config['enable'] else
                             self.TEST_WW_SEC)

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')
        # check the config for the flag to save wake words.

        self.save_utterances = listener_config.get('record_utterances', False)
        self.save_wake_words = listener_config.get('record_wake_words', False) \
            or self.upload_config['enable'] or self.config['opt_in']
        self.upload_lock = Lock()
        self.save_wake_words_dir = join(gettempdir(), 'mycroft_wake_words')
        self.filenames_to_upload = []
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
        self._stop_signaled = False
        self.hot_word_engines = hot_word_engines
def _read_data():
    """ Writes the dictionary of state data from the IPC directory.
    Returns:
        dict: loaded state information
    """
    managerIPCDir = os.path.join(get_ipc_directory(), "managers")

    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)

    data = {}
    try:
        with open(path, permission) as dispFile:

            if os.stat(str(dispFile.name)).st_size != 0:
                data = json.load(dispFile)

    except Exception as e:
        LOG.error(e)
        os.remove(path)
        _read_data()

    return data
Exemple #12
0
    def __init__(self):
        super().__init__('Mark2')

        self.i2c_channel = 1

        self.idle_screens = {}
        self.override_idle = None
        self.idle_next = 0  # Next time the idle screen should trigger
        self.idle_lock = Lock()

        self.settings['auto_brightness'] = False
        self.settings['use_listening_beep'] = True

        self.has_show_page = False  # resets with each handler

        # Volume indicatior
        self.thread = None
        self.pa = pyaudio.PyAudio()
        try:
            self.listener_file = os.path.join(get_ipc_directory(), 'mic_level')
            self.st_results = os.stat(self.listener_file)
        except Exception:
            self.listener_file = None
            self.st_results = None
        self.max_amplitude = 0.001

        # System volume
        self.volume = 0.5
        self.muted = False
        self.get_hardware_volume()  # read from the device
Exemple #13
0
    def __init__(self, wake_word_recognizer):

        self.config = Configuration.get()
        listener_config = self.config.get('listener')
        self.upload_config = listener_config.get('wake_word_upload')
        self.wake_word_name = wake_word_recognizer.key_phrase

        self.overflow_exc = listener_config.get('overflow_exception', False)

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')
        # check the config for the flag to save wake words.

        self.save_utterances = listener_config.get('record_utterances', False)
        self.save_wake_words = listener_config.get('record_wake_words') \
            or self.upload_config['enable'] or self.config['opt_in']
        self.upload_lock = Lock()
        self.save_wake_words_dir = join(gettempdir(), 'mycroft_wake_words')
        self.filenames_to_upload = []
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
        self._stop_signaled = False

        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = wake_word_recognizer.num_phonemes
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.TEST_WW_SEC = num_phonemes * len_phoneme
        self.SAVED_WW_SEC = 3 if self.save_wake_words else self.TEST_WW_SEC
        self.account_id = '0'
Exemple #14
0
    def __init__(self, wake_word_recognizer):
        self.config = Configuration.get()
        listener_config = self.config.get('listener')
        self.upload_url = listener_config['wake_word_upload']['url']
        self.upload_disabled = listener_config['wake_word_upload']['disable']
        self.wake_word_name = wake_word_recognizer.key_phrase

        self.overflow_exc = listener_config.get('overflow_exception', False)

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')

        # Check the config for the flag to save wake words, utterances
        # and for a path under which to save them
        self.save_utterances = listener_config.get('save_utterances', False)
        self.save_wake_words = listener_config.get('record_wake_words', False)
        self.save_path = listener_config.get('save_path', gettempdir())
        self.saved_wake_words_dir = join(self.save_path, 'mycroft_wake_words')
        if self.save_wake_words and not isdir(self.saved_wake_words_dir):
            os.mkdir(self.saved_wake_words_dir)
        self.saved_utterances_dir = join(self.save_path, 'mycroft_utterances')
        if self.save_utterances and not isdir(self.saved_utterances_dir):
            os.mkdir(self.saved_utterances_dir)

        self.upload_lock = Lock()
        self.filenames_to_upload = []
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")

        # Signal statuses
        self._stop_signaled = False
        self._listen_triggered = False

        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = wake_word_recognizer.num_phonemes
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.TEST_WW_SEC = num_phonemes * len_phoneme
        self.SAVED_WW_SEC = max(3, self.TEST_WW_SEC)

        self._account_id = None

        # The maximum seconds a phrase can be recorded,
        # provided there is noise the entire time
        self.recording_timeout = listener_config.get('recording_timeout',
                                                     self.RECORDING_TIMEOUT)

        # The maximum time it will continue to record silence
        # when not enough noise has been detected
        self.recording_timeout_with_silence = listener_config.get(
            'recording_timeout_with_silence',
            self.RECORDING_TIMEOUT_WITH_SILENCE)
Exemple #15
0
    def __init__(self, wake_word_recognizer):
        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = len(listener_config.get('phonemes').split())
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.SAVED_WW_SEC = num_phonemes * len_phoneme

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')
        # check the config for the flag to save wake words.
        self.save_wake_words = listener_config.get('record_wake_words')
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
        self._stop_signaled = False
    def __init__(self, wake_word_recognizer):
        # The maximum audio in seconds to keep for transcribing a phrase
        # The wake word must fit in this time
        num_phonemes = len(listener_config.get('phonemes').split())
        len_phoneme = listener_config.get('phoneme_duration', 120) / 1000.0
        self.SAVED_WW_SEC = num_phonemes * len_phoneme

        speech_recognition.Recognizer.__init__(self)
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')
        # check the config for the flag to save wake words.
        self.save_wake_words = listener_config.get('record_wake_words')
        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")
        self._stop_signaled = False
Exemple #17
0
    def __init__(self, wake_word_recognizer, watchdog=None):
        self._watchdog = watchdog or (lambda: None)  # Default to dummy func
        self.config = Configuration.get()
        listener_config = self.config.get('listener')
        self.upload_url = listener_config['wake_word_upload']['url']
        self.upload_disabled = listener_config['wake_word_upload']['disable']
        self.wake_word_name = wake_word_recognizer.key_phrase

        self.overflow_exc = listener_config.get('overflow_exception', False)

        super().__init__()
        self.wake_word_recognizer = wake_word_recognizer
        self.audio = pyaudio.PyAudio()
        self.multiplier = listener_config.get('multiplier')
        self.energy_ratio = listener_config.get('energy_ratio')

        # Check the config for the flag to save wake words, utterances
        # and for a path under which to save them
        self.save_utterances = listener_config.get('save_utterances', False)
        self.save_wake_words = listener_config.get('record_wake_words', False)
        self.save_path = listener_config.get('save_path', gettempdir())
        self.saved_wake_words_dir = join(self.save_path, 'mycroft_wake_words')
        if self.save_wake_words and not isdir(self.saved_wake_words_dir):
            os.mkdir(self.saved_wake_words_dir)
        self.saved_utterances_dir = join(self.save_path, 'mycroft_utterances')
        if self.save_utterances and not isdir(self.saved_utterances_dir):
            os.mkdir(self.saved_utterances_dir)

        self.mic_level_file = os.path.join(get_ipc_directory(), "mic_level")

        # Signal statuses
        self._stop_signaled = False
        self._listen_triggered = False

        self._account_id = None

        # The maximum seconds a phrase can be recorded,
        # provided there is noise the entire time
        self.recording_timeout = listener_config.get('recording_timeout',
                                                     self.RECORDING_TIMEOUT)

        # The maximum time it will continue to record silence
        # when not enough noise has been detected
        self.recording_timeout_with_silence = listener_config.get(
            'recording_timeout_with_silence',
            self.RECORDING_TIMEOUT_WITH_SILENCE)
Exemple #18
0
def main():
    # Monitor system logs
    start_log_monitor("/var/log/mycroft/skills.log")
    start_log_monitor("/var/log/mycroft/voice.log")
    # logs when using Debian package   TODO: Unify all
    start_log_monitor("/var/log/mycroft-skills.log")
    start_log_monitor("/var/log/mycroft-speech-client.log")

    # Monitor IPC file containing microphone level info
    start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))
    if '--simple' in sys.argv:
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        simple_cli()
    else:
        load_settings()
        curses.wrapper(gui_main)
        curses.endwin()
        save_settings()
def main():
    # Monitor system logs
    start_log_monitor("/var/log/mycroft/skills.log")
    start_log_monitor("/var/log/mycroft/voice.log")
    # logs when using Debian package   TODO: Unify all
    start_log_monitor("/var/log/mycroft-skills.log")
    start_log_monitor("/var/log/mycroft-speech-client.log")

    # Monitor IPC file containing microphone level info
    start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))
    if '--simple' in sys.argv:
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        simple_cli()
    else:
        load_settings()
        curses.wrapper(gui_main)
        curses.endwin()
        save_settings()
    def initialize(self):
        self.filename = os.path.join(get_ipc_directory(), "mic_level")
        self.audio_service = AudioService(self.bus)
        self.mixer = Mixer()
        self.schedule_repeating_event(self.auto_set_volume, None, 5,
                                      'AutoVolume')
        self.schedule_repeating_event(self.mesure_mic_thresh, None, 1,
                                      'AutoVolume_messure')

        self.autovolume = True
        if self.settings.get('High volume') is None:
            self.settings['High volume'] = 75
        if self.settings.get('Normal volume') is None:
            self.settings['Normal volume'] = 60
        if self.settings.get('Low volume') is None:
            self.settings['Low volume'] = 35

        self.add_event('recognizer_loop:record_begin',
                       self.handle_listener_started)
        self.add_event('recognizer_loop:record_end',
                       self.handle_listener_ended)

        wait_while_speaking()
        with io.open(self.filename, 'r') as fh:
            while True:
                line = fh.readline()
                if line == "":
                    break
                # Ex:Energy:  cur=4 thresh=1.5
                parts = line.split("=")
                meter_thresh = float(parts[-1])

        if self.settings.get('Highest messurement') is None:
            self.settings['Highest messurement'] = meter_thresh
        if self.settings.get('Lowest messurement') is None:
            self.settings['Lowest messurement'] = meter_thresh

        self.volume = int(self.settings.get('Low volume'))
        self.meter_thresh = 0
        self.meter_high = meter_thresh
        self.meter_low = meter_thresh
        self.meter_thresh_list = []
        self.meter_thresh_list.append(meter_thresh)
def _write_data(dictionary):
    """ Writes the dictionary of state data to the IPC directory.

    Args:
        dictionary (dict): information to place in the 'disp_info' file
    """

    managerIPCDir = os.path.join(get_ipc_directory(), "managers")
    # change read/write permissions based on if file exists or not
    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r+" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)
        os.chmod(managerIPCDir, 0o777)

    try:
        with open(path, permission) as dispFile:

            # check if file is empty
            if os.stat(str(dispFile.name)).st_size != 0:
                data = json.load(dispFile)

            else:
                data = {}
                LOG.info("Display Manager is creating " + dispFile.name)

            for key in dictionary:
                data[key] = dictionary[key]

            dispFile.seek(0)
            dispFile.write(json.dumps(data))
            dispFile.truncate()

        os.chmod(path, 0o777)

    except Exception as e:
        LOG.error(e)
        LOG.error("Error found in display manager file, deleting...")
        os.remove(path)
        _write_data(dictionary)
Exemple #22
0
def _write_data(dictionary):
    """ Writes the dictionary of state data to the IPC directory.

    Args:
        dictionary (dict): information to place in the 'disp_info' file
    """

    managerIPCDir = os.path.join(get_ipc_directory(), "managers")
    # change read/write permissions based on if file exists or not
    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r+" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)
        os.chmod(managerIPCDir, 0o777)

    try:
        with open(path, permission) as dispFile:

            # check if file is empty
            if os.stat(str(dispFile.name)).st_size != 0:
                data = json.load(dispFile)

            else:
                data = {}
                LOG.info("Display Manager is creating " + dispFile.name)

            for key in dictionary:
                data[key] = dictionary[key]

            dispFile.seek(0)
            dispFile.write(json.dumps(data))
            dispFile.truncate()

        os.chmod(path, 0o777)

    except Exception as e:
        LOG.error(e)
        LOG.error("Error found in display manager file, deleting...")
        os.remove(path)
        _write_data(dictionary)
Exemple #23
0
    def __init__(self):
        super().__init__("Mark2")

        self.idle_count = 99
        self.idle_screens = {}
        self.override_idle = None

        self.hourglass_info = {}
        self.interaction_id = 0

        self.settings['auto_brightness'] = False
        self.settings['auto_dim_eyes'] = True
        self.settings['use_listening_beep'] = True

        self.has_show_page = False  # resets with each handler

        # Volume indicatior
        self.setup_mic_listening()
        self.listener_file = os.path.join(get_ipc_directory(), "mic_level")
        self.st_results = os.stat(self.listener_file)
        self.max_amplitude = 0
Exemple #24
0
    def __init__(self):
        super().__init__("MycroftDesktopApplet")

        self.previousMessage = ""
        self.idle_screens = {}
        self.override_idle = None
        self.idle_next = 0  # Next time the idle screen should trigger
        self.idle_lock = Lock()

        self.has_show_page = False  # resets with each handler
        self.any_has_show_page = False

        self.settings['use_listening_beep'] = True

        # Volume indicatior
        self.thread = None
        self.pa = pyaudio.PyAudio()
        try:
            self.listener_file = os.path.join(get_ipc_directory(), 'mic_level')
            self.st_results = os.stat(self.listener_file)
        except Exception:
            self.listener_file = None
            self.st_results = None
        self.max_amplitude = 0.001
Exemple #25
0
add_log_message("  v--- OLDEST ---v")

# Find the correct log path relative to this script
scriptPath = os.path.dirname(os.path.realpath(__file__))
localLogPath = os.path.realpath(scriptPath + "/../../../scripts/logs")

# Monitor relative logs (for Github installs)
start_log_monitor(localLogPath + "/mycroft-skills.log")
start_log_monitor(localLogPath + "/mycroft-voice.log")

# Also monitor system logs (for package installs)
start_log_monitor("/var/log/mycroft-skills.log")
start_log_monitor("/var/log/mycroft-speech-client.log")

# Monitor IPC file containing microphone level info
start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))


def main():
    if bSimple:
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        simple_cli()
    else:
        load_settings()
        curses.wrapper(gui_main)
        curses.endwin()
        save_settings()


if __name__ == "__main__":
Exemple #26
0
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mycroft Core.  If not, see <http://www.gnu.org/licenses/>.
from threading import Thread, Timer
from mycroft.messagebus.client.ws import WebsocketClient
from mycroft.configuration import ConfigurationManager
from mycroft.util import get_ipc_directory
import json
import os
from logging import getLogger

__author__ = 'connorpenrod', 'michaelnguyen'

LOG = getLogger("Display Manager (mycroft.client.enclosure)")
managerIPCDir = os.path.join(get_ipc_directory(), "managers")


def _write_data(dictionary):
    """Writes the parama as JSON to the
        IPC dir (/tmp/mycroft/ipc/managers)
        args:
            dict: dictionary
    """

    # change read/write permissions based on if file exists or not
    path = os.path.join(managerIPCDir, "disp_info")
    permission = "r+" if os.path.isfile(path) else "w+"

    if permission == "w+" and os.path.isdir(managerIPCDir) is False:
        os.makedirs(managerIPCDir)
Exemple #27
0

# Find the correct log path relative to this script
scriptPath = os.path.dirname(os.path.realpath(__file__))
localLogPath = os.path.realpath(scriptPath + "/../../../scripts/logs")

# Monitor relative logs (for Github installs)
start_log_monitor(localLogPath + "/mycroft-skills.log")
start_log_monitor(localLogPath + "/mycroft-voice.log")

# Also monitor system logs (for package installs)
start_log_monitor("/var/log/mycroft-skills.log")
start_log_monitor("/var/log/mycroft-speech-client.log")

# Monitor IPC file containing microphone level info
start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))


def main():
    if bSimple:
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__
        simple_cli()
    else:
        load_settings()
        curses.wrapper(gui_main)
        curses.endwin()
        save_settings()

if __name__ == "__main__":
    main()