client/text/__main__.py
Go to the documentation of this file.
1 # Copyright 2017 Mycroft AI Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 import sys
16 import io
17 import os.path
18 import curses
19 from mycroft.util import get_ipc_directory
20 from .text_client import (
21  load_settings, save_settings, simple_cli, gui_main,
22  start_log_monitor, start_mic_monitor, connect_to_mycroft
23  )
24 
25 sys.stdout = io.StringIO()
26 sys.stderr = io.StringIO()
27 
28 
29 def custom_except_hook(exctype, value, traceback):
30  print(sys.stdout.getvalue(), file=sys.__stdout__)
31  print(sys.stderr.getvalue(), file=sys.__stderr__)
32  sys.stdout, sys.stderr = sys.__stdout__, sys.__stderr__
33  sys.__excepthook__(exctype, value, traceback)
34 
35 
36 sys.excepthook = custom_except_hook # noqa
37 
38 
39 def main():
40  # Monitor system logs
41  start_log_monitor("/var/log/mycroft/skills.log")
42  start_log_monitor("/var/log/mycroft/voice.log")
43  # logs when using Debian package TODO: Unify all
44  start_log_monitor("/var/log/mycroft-skills.log")
45  start_log_monitor("/var/log/mycroft-speech-client.log")
46 
47  # Monitor IPC file containing microphone level info
48  start_mic_monitor(os.path.join(get_ipc_directory(), "mic_level"))
49 
51  if '--simple' in sys.argv:
52  sys.stdout = sys.__stdout__
53  sys.stderr = sys.__stderr__
54  simple_cli()
55  else:
57  curses.wrapper(gui_main)
58  curses.endwin()
60 
61 
62 if __name__ == "__main__":
63  main()
def custom_except_hook(exctype, value, traceback)
def get_ipc_directory(domain=None)
Definition: signal.py:25


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