Home | Trees | Indices | Help |
---|
|
1 # Software License Agreement (BSD License) 2 # 3 # Copyright (c) 2012, Fraunhofer FKIE/US, Alexander Tiderko 4 # All rights reserved. 5 # 6 # Redistribution and use in source and binary forms, with or without 7 # modification, are permitted provided that the following conditions 8 # are met: 9 # 10 # * Redistributions of source code must retain the above copyright 11 # notice, this list of conditions and the following disclaimer. 12 # * Redistributions in binary form must reproduce the above 13 # copyright notice, this list of conditions and the following 14 # disclaimer in the documentation and/or other materials provided 15 # with the distribution. 16 # * Neither the name of Fraunhofer nor the names of its 17 # contributors may be used to endorse or promote products derived 18 # from this software without specific prior written permission. 19 # 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 # POSSIBILITY OF SUCH DAMAGE. 32 import os 33 from datetime import datetime 34 35 from python_qt_binding import QtGui 36 from python_qt_binding import QtCore 37 from python_qt_binding import loadUi 38 39 from rosgraph_msgs.msg import Log 40 41 from .rosout_listener import RosoutListener 4244 ''' 45 The collect the the warning log messages from rosout and print it in a text 46 browser. 47 ''' 48 49 added_signal = QtCore.Signal(int, int, int, int) 50 ''' 51 added_signal will be emitted on adding a new log entry. The parameter contains 52 the current count of messages (INFO, WARN, ERROR, FATAL) 53 ''' 54 55 cleared_signal = QtCore.Signal() 5616658 ''' 59 Creates the window, connects the signals and init the class. 60 ''' 61 QtGui.QDockWidget.__init__(self, parent) 62 self._log_info_count = 0 63 self._log_warn_count = 0 64 self._log_err_count = 0 65 self._log_fatal_count = 0 66 # load the UI file 67 log_dock_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'LogDockWidget.ui') 68 loadUi(log_dock_file, self) 69 self.hide() 70 # connect to the button signals 71 self.clearCloseButton.clicked.connect(self._on_log_clear_close_clicked) 72 self.closeButton.clicked.connect(self.hide) 73 # initialize the listener to the rosout topic 74 self._rosout_listener = RosoutListener() 75 self._rosout_listener.roswarn_signal.connect(self._on_roslog_warn) 76 self._rosout_listener.roserr_signal.connect(self._on_roslog_err) 77 self._rosout_listener.rosfatal_signal.connect(self._on_roslog_fatal) 78 self._rosout_listener.registerByROS()7981 ''' 82 Returns the count all current viewed log messages. 83 ''' 84 return self._log_info_count + self._log_warn_count + self._log_err_count + self._log_fatal_count8587 ''' 88 Removes all log messages and emit the `cleared_signal`. 89 ''' 90 self._log_info_count = 0 91 self._log_warn_count = 0 92 self._log_err_count = 0 93 self._log_fatal_count = 0 94 self.textBrowser.clear() 95 self.infoLabel.setText('') 96 self.cleared_signal.emit()9799 ''' 100 Unregister the listener thread from the `/rosout` topic. This method must be 101 called at the exit! 102 ''' 103 self._rosout_listener.stop()104106 self._log_info_count += 1 107 text = ('<pre style="padding:10px;"><dt><font color="#000000">' 108 '<b>[INFO]</b> %s (%s:%s:%s):' 109 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 110 msg.file, msg.function, msg.line, 111 msg.msg)) 112 self.textBrowser.append(text) 113 self._update_info_label()114116 self._log_warn_count += 1 117 text = ('<pre style="padding:10px;"><dt><font color="#FE9A2E">' 118 '<b>[WARN]</b> %s (%s:%s:%s):' 119 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 120 msg.file, msg.function, msg.line, 121 msg.msg)) 122 self.textBrowser.append(text) 123 self._update_info_label()124126 self._log_err_count += 1 127 text = ('<pre style="padding:10px;"><dt><font color="#DF0101">' 128 '<b>[ERROR]</b> %s (%s:%s:%s):' 129 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 130 msg.file, msg.function, msg.line, 131 msg.msg)) 132 self.textBrowser.append(text) 133 self._update_info_label()134136 self._log_fatal_count += 1 137 text = ('<pre style="padding:10px;"><dt><font color="#610B0B">' 138 '<b>[FATAL]</b> %s (%s:%s:%s):' 139 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 140 msg.file, msg.function, msg.line, 141 msg.msg)) 142 self.textBrowser.append(text) 143 self._update_info_label()144 148150 info_text = '' 151 if self._log_info_count > 0: 152 info_text = '%s INFO: %d '%(info_text, self._log_info_count) 153 if self._log_warn_count > 0: 154 info_text = '%s WARN: %d '%(info_text, self._log_warn_count) 155 if self._log_err_count > 0: 156 info_text = '%s ERROR: %d '%(info_text, self._log_err_count) 157 if self._log_fatal_count > 0: 158 info_text = '%s FATAL: %d'%(info_text, self._log_fatal_count) 159 self.infoLabel.setText(info_text) 160 self.added_signal.emit(self._log_info_count, self._log_warn_count, 161 self._log_err_count, self._log_fatal_count)162
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Oct 6 11:14:56 2014 | http://epydoc.sourceforge.net |