| 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 .rosout_listener import RosoutListener 4042 ''' 43 The collect the the warning log messages from rosout and print it in a text 44 browser. 45 ''' 46 47 added_signal = QtCore.Signal(int, int, int, int) 48 ''' 49 added_signal will be emitted on adding a new log entry. The parameter contains 50 the current count of messages (INFO, WARN, ERROR, FATAL) 51 ''' 52 53 cleared_signal = QtCore.Signal() 5416456 ''' 57 Creates the window, connects the signals and init the class. 58 ''' 59 QtGui.QDockWidget.__init__(self, parent) 60 self._log_info_count = 0 61 self._log_warn_count = 0 62 self._log_err_count = 0 63 self._log_fatal_count = 0 64 # load the UI file 65 log_dock_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'LogDockWidget.ui') 66 loadUi(log_dock_file, self) 67 self.hide() 68 # connect to the button signals 69 self.clearCloseButton.clicked.connect(self._on_log_clear_close_clicked) 70 self.closeButton.clicked.connect(self.hide) 71 # initialize the listener to the rosout topic 72 self._rosout_listener = RosoutListener() 73 self._rosout_listener.roswarn_signal.connect(self._on_roslog_warn) 74 self._rosout_listener.roserr_signal.connect(self._on_roslog_err) 75 self._rosout_listener.rosfatal_signal.connect(self._on_roslog_fatal) 76 self._rosout_listener.registerByROS()7779 ''' 80 Returns the count all current viewed log messages. 81 ''' 82 return self._log_info_count + self._log_warn_count + self._log_err_count + self._log_fatal_count8385 ''' 86 Removes all log messages and emit the `cleared_signal`. 87 ''' 88 self._log_info_count = 0 89 self._log_warn_count = 0 90 self._log_err_count = 0 91 self._log_fatal_count = 0 92 self.textBrowser.clear() 93 self.infoLabel.setText('') 94 self.cleared_signal.emit()9597 ''' 98 Unregister the listener thread from the `/rosout` topic. This method must be 99 called at the exit! 100 ''' 101 self._rosout_listener.stop()102104 self._log_info_count += 1 105 text = ('<pre style="padding:10px;"><dt><font color="#000000">' 106 '<b>[INFO]</b> %s (%s:%s:%s):' 107 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 108 msg.file, msg.function, msg.line, 109 msg.msg)) 110 self.textBrowser.append(text) 111 self._update_info_label()112114 self._log_warn_count += 1 115 text = ('<pre style="padding:10px;"><dt><font color="#FE9A2E">' 116 '<b>[WARN]</b> %s (%s:%s:%s):' 117 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 118 msg.file, msg.function, msg.line, 119 msg.msg)) 120 self.textBrowser.append(text) 121 self._update_info_label()122124 self._log_err_count += 1 125 text = ('<pre style="padding:10px;"><dt><font color="#DF0101">' 126 '<b>[ERROR]</b> %s (%s:%s:%s):' 127 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 128 msg.file, msg.function, msg.line, 129 msg.msg)) 130 self.textBrowser.append(text) 131 self._update_info_label()132134 self._log_fatal_count += 1 135 text = ('<pre style="padding:10px;"><dt><font color="#610B0B">' 136 '<b>[FATAL]</b> %s (%s:%s:%s):' 137 '<br>%s</font></dt></pre>'%(self._formated_ts(msg.header.stamp), 138 msg.file, msg.function, msg.line, 139 msg.msg)) 140 self.textBrowser.append(text) 141 self._update_info_label()142 146148 info_text = '' 149 if self._log_info_count > 0: 150 info_text = '%s INFO: %d '%(info_text, self._log_info_count) 151 if self._log_warn_count > 0: 152 info_text = '%s WARN: %d '%(info_text, self._log_warn_count) 153 if self._log_err_count > 0: 154 info_text = '%s ERROR: %d '%(info_text, self._log_err_count) 155 if self._log_fatal_count > 0: 156 info_text = '%s FATAL: %d'%(info_text, self._log_fatal_count) 157 self.infoLabel.setText(info_text) 158 self.added_signal.emit(self._log_info_count, self._log_warn_count, 159 self._log_err_count, self._log_fatal_count)160
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Fri Aug 28 11:39:31 2015 | http://epydoc.sourceforge.net |