mycroft_message_bus.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 #!/usr/bin/env python
16 import rospy
17 from std_msgs.msg import String
18 
19 from tornado import autoreload, web, ioloop
20 
21 from mycroft.configuration import Configuration
22 from mycroft.lock import Lock # creates/supports PID locking file
23 from mycroft.messagebus.service.ws import WebsocketEventHandler
24 from mycroft.util import validate_param, reset_sigint_handler, create_daemon, \
25  wait_for_exit_signal
26 
27 settings = {
28  'debug': True
29 }
30 
31 
32 def main():
33  rospy.init_node('mycroft_message_bus')
34  rospy.loginfo(rospy.get_caller_id() + " started")
35 
36  import tornado.options
38  lock = Lock("service")
39  tornado.options.parse_command_line()
40 
41  def reload_hook():
42  """ Hook to release lock when autoreload is triggered. """
43  lock.delete()
44 
45  autoreload.add_reload_hook(reload_hook)
46 
47  config = Configuration.get().get("websocket")
48 
49  host = config.get("host")
50  port = config.get("port")
51  route = config.get("route")
52  validate_param(host, "websocket.host")
53  validate_param(port, "websocket.port")
54  validate_param(route, "websocket.route")
55 
56  routes = [
57  (route, WebsocketEventHandler)
58  ]
59  application = web.Application(routes, **settings)
60  application.listen(port, host)
61  create_daemon(ioloop.IOLoop.instance().start)
62 
64  rospy.spin()
65 
66 
67 if __name__ == "__main__":
68  main()
def create_daemon(target, args=(), kwargs=None)
def validate_param(value, name)
def get(phrase, lang=None, context=None)


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